From c27ba19da3b70381bef83ea978036f42e527af50 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 21 Jul 2016 07:13:20 -0700 Subject: [PATCH] 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 --- .../phame/editor/PhameBlogEditor.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php index ea1c132f64..14f63f51ac 100644 --- a/src/applications/phame/editor/PhameBlogEditor.php +++ b/src/applications/phame/editor/PhameBlogEditor.php @@ -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) {