@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix string truncation calls all over the codebase.

Summary: Fixes T6608, though I'll also clean up the comment for PhutilStringTruncator in another diff. If I understand correctly, before T1191, MySQL column length was by character count and post T1191 its by byte count. Ergo, most of these changes are going from codepoint -> bytes. See test plan for complete list of what was and was not done.

Test Plan:
Thought very carefully about each callsite and made changes as appropos. "Display" means the string is clearly used for display-only purposes and correctly uses "glyph" already.

grep -rn PhutilUTF8StringTruncator *

applications/calendar/query/PhabricatorCalendarEventSearchEngine.php:217: ->addAttribute(id(new PhutilUTF8StringTruncator()) -- display
applications/chatlog/controller/PhabricatorChatLogChannelLogController.php:111: $author = id(new PhutilUTF8StringTruncator()) -- display
applications/conduit/method/ConduitConnectConduitAPIMethod.php:62: $client_description = id(new PhutilUTF8StringTruncator()) -- was codepoint, changed to bytes
applications/conpherence/view/ConpherenceFileWidgetView.php:22: ->setFileName(id(new PhutilUTF8StringTruncator()) -- display
applications/differential/controller/DifferentialDiffViewController.php:65: id(new PhutilUTF8StringTruncator()) -- display
applications/differential/event/DifferentialHovercardEventListener.php:69: id(new PhutilUTF8StringTruncator()) -- display
applications/differential/parser/DifferentialCommitMessageParser.php:144: $short = id(new PhutilUTF8StringTruncator()) -- was glyphs, made to bytes
applications/differential/view/DifferentialLocalCommitsView.php:80: $summary = id(new PhutilUTF8StringTruncator()) -- display
applications/diffusion/controller/DiffusionBrowseFileController.php:686: id(new PhutilUTF8StringTruncator()) -- display
applications/feed/story/PhabricatorFeedStory.php:392: $text = id(new PhutilUTF8StringTruncator()) -- display, unless people are saving the results of renderSummary() somewhere...
applications/harbormaster/storage/build/HarbormasterBuild.php:216: $log_source = id(new PhutilUTF8StringTruncator()) -- was codepoints now bytes
applications/herald/storage/transcript/HeraldObjectTranscript.php:55: // NOTE: PhutilUTF8StringTruncator has huge runtime for giant strings. -- not applicable
applications/maniphest/export/ManiphestExcelDefaultFormat.php:107: id(new PhutilUTF8StringTruncator()) -- bytes
applications/metamta/storage/PhabricatorMetaMTAMail.php:587: $body = id(new PhutilUTF8StringTruncator()) -- bytes
applications/people/event/PhabricatorPeopleHovercardEventListener.php:62: id(new PhutilUTF8StringTruncator()) -- display
applications/phame/conduit/PhameCreatePostConduitAPIMethod.php:93: id(new PhutilUTF8StringTruncator()) -- was codepoints, now bytes
applications/pholio/storage/PholioTransaction.php:300: id(new PhutilUTF8StringTruncator()) -- display
applications/phortune/provider/PhortuneBalancedPaymentProvider.php:147: $charge_as = id(new PhutilUTF8StringTruncator()) -- bytes
applications/ponder/storage/PonderAnswerTransaction.php:86: id(new PhutilUTF8StringTruncator()) -- display
applications/ponder/storage/PonderQuestionTransaction.php:267: id(new PhutilUTF8StringTruncator()) -- display
applications/ponder/storage/PonderQuestionTransaction.php:276: id(new PhutilUTF8StringTruncator()) -- display
applications/repository/storage/PhabricatorRepositoryCommitData.php:43: $summary = id(new PhutilUTF8StringTruncator()) -- was codepoints, now bytes
applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php:20: $data->setAuthorName(id(new PhutilUTF8StringTruncator()) -- was codepoints, now bytes
applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php:158: $item->addAttribute(id(new PhutilUTF8StringTruncator()) -- display
infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php:317: $host = id(new PhutilUTF8StringTruncator()) -- bytes
view/form/control/AphrontFormPolicyControl.php:61: $policy_short_name = id(new PhutilUTF8StringTruncator()) -- glyphs, probably display only

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6608

Differential Revision: https://secure.phabricator.com/D11219

+6 -6
+1 -1
src/applications/conduit/method/ConduitConnectConduitAPIMethod.php
··· 60 60 $client_version = (int)$request->getValue('clientVersion'); 61 61 $client_description = (string)$request->getValue('clientDescription'); 62 62 $client_description = id(new PhutilUTF8StringTruncator()) 63 - ->setMaximumCodepoints(255) 63 + ->setMaximumBytes(255) 64 64 ->truncateString($client_description); 65 65 $username = (string)$request->getValue('user'); 66 66
+1 -1
src/applications/differential/parser/DifferentialCommitMessageParser.php
··· 142 142 $terminal = '...'; 143 143 $title = $fields[$key_title]; 144 144 $short = id(new PhutilUTF8StringTruncator()) 145 - ->setMaximumGlyphs(250) 145 + ->setMaximumBytes(250) 146 146 ->setTerminator($terminal) 147 147 ->truncateString($title); 148 148
+1 -1
src/applications/harbormaster/storage/build/HarbormasterBuild.php
··· 214 214 $log_type) { 215 215 216 216 $log_source = id(new PhutilUTF8StringTruncator()) 217 - ->setMaximumCodepoints(250) 217 + ->setMaximumBytes(250) 218 218 ->truncateString($log_source); 219 219 220 220 $log = HarbormasterBuildLog::initializeNewBuildLog($build_target)
+1 -1
src/applications/phame/conduit/PhameCreatePostConduitAPIMethod.php
··· 91 91 $phame_title = $request->getValue( 92 92 'phameTitle', 93 93 id(new PhutilUTF8StringTruncator()) 94 - ->setMaximumCodepoints(64) 94 + ->setMaximumBytes(64) 95 95 ->truncateString($title)); 96 96 $post->setPhameTitle(PhabricatorSlug::normalize($phame_title)); 97 97 $post->setBody($body);
+1 -1
src/applications/repository/storage/PhabricatorRepositoryCommitData.php
··· 41 41 $summary = phutil_split_lines($message, $retain_endings = false); 42 42 $summary = head($summary); 43 43 $summary = id(new PhutilUTF8StringTruncator()) 44 - ->setMaximumCodepoints(self::SUMMARY_MAX_LENGTH) 44 + ->setMaximumBytes(self::SUMMARY_MAX_LENGTH) 45 45 ->truncateString($summary); 46 46 47 47 return $summary;
+1 -1
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 18 18 } 19 19 $data->setCommitID($commit->getID()); 20 20 $data->setAuthorName(id(new PhutilUTF8StringTruncator()) 21 - ->setMaximumCodepoints(255) 21 + ->setMaximumBytes(255) 22 22 ->truncateString((string)$author)); 23 23 24 24 $data->setCommitDetail('authorName', $ref->getAuthorName());