From fc6bfbdb103f0f66e5782c34510956b080268e81 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 13 Dec 2016 09:29:12 -0800 Subject: [PATCH] Truncate the one-line diff update summary when updating a revision to 250 bytes Summary: Fixes T7899. If you create or update a revision and type an enormously long first line, we currently fatal trying to insert it into the database. This text is only used to show a single-line summary of the diff in the "History" tab, which should probably be updated anyway. For now, stop fataling. Test Plan: Uploaded a diff with the description "MMMM..." (thousands of them). Before patch: fatal on description being too long. After patch: beautiful "MMMM" summary. Reviewers: chad Reviewed By: chad Maniphest Tasks: T7899 Differential Revision: https://secure.phabricator.com/D17038 --- .../conduit/DifferentialConduitAPIMethod.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/applications/differential/conduit/DifferentialConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialConduitAPIMethod.php index fdcf4395dd..111e0f04b4 100644 --- a/src/applications/differential/conduit/DifferentialConduitAPIMethod.php +++ b/src/applications/differential/conduit/DifferentialConduitAPIMethod.php @@ -124,8 +124,15 @@ abstract class DifferentialConduitAPIMethod extends ConduitAPIMethod { $message = $request->getValue('message'); if (strlen($message)) { // This is a little awkward, and should maybe move inside the transaction - // editor. It largely exists for legacy reasons. + // editor. It largely exists for legacy reasons. See some discussion in + // T7899. $first_line = head(phutil_split_lines($message, false)); + + $first_line = id(new PhutilUTF8StringTruncator()) + ->setMaximumBytes(250) + ->setMaximumGlyphs(80) + ->truncateString($first_line); + $diff->setDescription($first_line); $diff->save(); -- 2.51.2