1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Raise human-readable error messages for overlong Phame blog titles and subtitles

Summary:
Fixes T11358. Entering a too-long title/subtitle currently raises an unfriendly (database-level) error.

Raise a friendlier error.

Test Plan: {F1731533}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11358

Differential Revision: https://secure.phabricator.com/D16313
This commit is contained in:
epriestley 2016-07-21 07:13:20 -07:00
parent 56bd762dd3
commit c27ba19da3

View file

@ -160,6 +160,33 @@ final class PhameBlogEditor
$error->setIsMissingFieldError(true);
$errors[] = $error;
}
foreach ($xactions as $xaction) {
$new = $xaction->getNewValue();
if (phutil_utf8_strlen($new) > 64) {
$errors[] = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Invalid'),
pht(
'The selected blog title is too long. The maximum length '.
'of a blog title is 64 characters.'),
$xaction);
}
}
break;
case PhameBlogTransaction::TYPE_SUBTITLE:
foreach ($xactions as $xaction) {
$new = $xaction->getNewValue();
if (phutil_utf8_strlen($new) > 64) {
$errors[] = new PhabricatorApplicationTransactionValidationError(
$type,
pht('Invalid'),
pht(
'The selected blog subtitle is too long. The maximum length '.
'of a blog subtitle is 64 characters.'),
$xaction);
}
}
break;
case PhameBlogTransaction::TYPE_PARENTDOMAIN:
if (!$xactions) {