@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.

Get line count before truncating Paste snippets

Summary: Fixes T12338. Resolves an issue where long pastes would be truncated before getting a line count, resulting in an inaccurate line count being returned.

Test Plan: Made a large paste, verified that it displayed the correct number of lines.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Maniphest Tasks: T12338

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

authored by

Christopher Wetherill and committed by
faulconbridge
5fad7eb1 3f1ee679

+4 -3
+4 -3
src/applications/paste/query/PhabricatorPasteQuery.php
··· 185 185 $paste->getFilePHID(), 186 186 $paste->getLanguage(), 187 187 'snippet', 188 - 'v2', 188 + 'v2.1', 189 189 PhabricatorHash::digestForIndex($paste->getTitle()), 190 190 )); 191 191 } ··· 352 352 $snippet_type = PhabricatorPasteSnippet::FULL; 353 353 $snippet = $paste->getRawContent(); 354 354 355 + $lines = phutil_split_lines($snippet); 356 + $line_count = count($lines); 357 + 355 358 if (strlen($snippet) > 1024) { 356 359 $snippet_type = PhabricatorPasteSnippet::FIRST_BYTES; 357 360 $snippet = id(new PhutilUTF8StringTruncator()) ··· 360 363 ->truncateString($snippet); 361 364 } 362 365 363 - $lines = phutil_split_lines($snippet); 364 - $line_count = count($lines); 365 366 if ($line_count > 5) { 366 367 $snippet_type = PhabricatorPasteSnippet::FIRST_LINES; 367 368 $snippet = implode('', array_slice($lines, 0, 5));