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)
Thu, Apr 11, 3:53 AM
Unknown Object (File)
Sat, Mar 30, 6:22 PM
Unknown Object (File)
Sat, Mar 30, 4:00 AM
Unknown Object (File)
Fri, Mar 29, 7:18 AM
Unknown Object (File)
Mar 4 2024, 2:11 PM
Unknown Object (File)
Feb 25 2024, 4:17 PM
Unknown Object (File)
Feb 20 2024, 10:56 AM
Unknown Object (File)
Feb 10 2024, 4:28 PM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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!