Page MenuHomePhabricator

D17256.diff
No OneTemporary

D17256.diff

diff --git a/src/applications/paste/query/PhabricatorPasteQuery.php b/src/applications/paste/query/PhabricatorPasteQuery.php
--- a/src/applications/paste/query/PhabricatorPasteQuery.php
+++ b/src/applications/paste/query/PhabricatorPasteQuery.php
@@ -185,6 +185,7 @@
$paste->getFilePHID(),
$paste->getLanguage(),
'snippet',
+ 'v2',
PhabricatorHash::digestForIndex($paste->getTitle()),
));
}
@@ -294,7 +295,8 @@
$snippet_data = phutil_json_decode($caches[$key], true);
$snippet = new PhabricatorPasteSnippet(
phutil_safe_html($snippet_data['content']),
- $snippet_data['type']);
+ $snippet_data['type'],
+ $snippet_data['contentLineCount']);
$paste->attachSnippet($snippet);
$have_cache[$paste->getPHID()] = true;
} else {
@@ -326,6 +328,7 @@
$snippet_data = array(
'content' => (string)$snippet->getContent(),
'type' => (string)$snippet->getType(),
+ 'contentLineCount' => $snippet->getContentLineCount(),
);
$write_data[$this->getSnippetCacheKey($paste)] = phutil_json_encode(
$snippet_data);
@@ -358,7 +361,8 @@
}
$lines = phutil_split_lines($snippet);
- if (count($lines) > 5) {
+ $line_count = count($lines);
+ if ($line_count > 5) {
$snippet_type = PhabricatorPasteSnippet::FIRST_LINES;
$snippet = implode('', array_slice($lines, 0, 5));
}
@@ -368,7 +372,8 @@
$snippet,
$paste->getTitle(),
$paste->getLanguage()),
- $snippet_type);
+ $snippet_type,
+ $line_count);
}
private function highlightSource($source, $title, $language) {
diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php
--- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php
+++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php
@@ -166,7 +166,7 @@
$preview);
$created = phabricator_datetime($paste->getDateCreated(), $viewer);
- $line_count = count($lines);
+ $line_count = $paste->getSnippet()->getContentLineCount();
$line_count = pht(
'%s Line(s)',
new PhutilNumber($line_count));
diff --git a/src/applications/paste/snippet/PhabricatorPasteSnippet.php b/src/applications/paste/snippet/PhabricatorPasteSnippet.php
--- a/src/applications/paste/snippet/PhabricatorPasteSnippet.php
+++ b/src/applications/paste/snippet/PhabricatorPasteSnippet.php
@@ -8,10 +8,12 @@
private $content;
private $type;
+ private $contentLineCount;
- public function __construct($content, $type) {
+ public function __construct($content, $type, $content_line_count) {
$this->content = $content;
$this->type = $type;
+ $this->contentLineCount = $content_line_count;
}
public function getContent() {
@@ -21,4 +23,8 @@
public function getType() {
return $this->type;
}
+
+ public function getContentLineCount() {
+ return $this->contentLineCount;
+ }
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 8:15 AM (20 h, 51 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6906787
Default Alt Text
D17256.diff (3 KB)

Event Timeline