Page MenuHomePhabricator

Display paste line count alongside snippets
ClosedPublic

Authored by faulconbridge on Jan 26 2017, 11:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 8, 10:38 PM
Unknown Object (File)
Sat, Dec 7, 1:24 PM
Unknown Object (File)
Nov 12 2024, 8:01 PM
Unknown Object (File)
Nov 1 2024, 5:11 AM
Unknown Object (File)
Oct 17 2024, 4:56 PM
Unknown Object (File)
Oct 15 2024, 8:32 PM
Unknown Object (File)
Oct 14 2024, 9:51 AM
Unknown Object (File)
Sep 26 2024, 6:38 AM
Subscribers

Details

Summary

Fixes T11547. I think this mostly gets about addressing @epriestley's comments in D16465 and stores each paste's line count in its snippet so that we can display the actual number of lines in the paste rather than '5 Lines'. Let me know if this is on the right track!

Test Plan

Open /paste and see that each paste's actual line count is reported.

Diff Detail

Repository
rP Phabricator
Branch
contentLineCount
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 15392
Build 20274: Run Core Tests
Build 20273: arc lint + arc unit

Event Timeline

This looks mostly right to me -- one inline about a weird cast that I don't think we need? We probably don't need it on the other properties either, but there might be some subtle null vs empty string issue there. Here, count(...) only ever returns integers.

Also caught one real bug with count(...), I believe.

src/applications/paste/query/PhabricatorPasteQuery.php
331

Does removing this (string) cast break anything? I'd expect us to be OK without it, and the line count is probably usually an integer.

365

I think this never works, since you're counting $line_count, and count($any_integer) is 1, because PHP has ultimate god-tier language design.

I believe this should just be if ($line_count > 5), not if (count($line_count) > 5).

You can trigger the wrong behavior by doing this, I think:

  • Create a 10-line paste.
  • Nuke the caches (bin/cache purge --purge-general)
  • View the paste list.
  • Content isn't summarized, or doesn't have the "... snip 5 more lines ..." note or something like that?
This revision now requires changes to proceed.Jan 26 2017, 11:47 PM

Good catches, thanks! Fixing those up now.

src/applications/paste/query/PhabricatorPasteQuery.php
331

I would love to see a fraction of a line, though.

365

Oh, you're totally right. That was the carnage of a bad copy-pasta job when I tried to move the diff from my work to home computer this evening.

faulconbridge edited edge metadata.

Learning to count

Looks good to me, thanks!

I added you to Blessed Committers so you should be able to land this yourself. That project description has some instructions.

You're also now a member of Community, granting you sweeping janitorial powers on this install.

This revision is now accepted and ready to land.Jan 27 2017, 12:05 AM
This revision was automatically updated to reflect the committed changes.

Awesome, thanks for the scary-quick review!