Page MenuHomePhabricator

File names should be editable.
ClosedPublic

Authored by lpriestley on Apr 26 2015, 9:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 8:19 AM
Unknown Object (File)
Mon, Apr 8, 12:38 PM
Unknown Object (File)
Sat, Apr 6, 3:36 PM
Unknown Object (File)
Tue, Apr 2, 1:39 PM
Unknown Object (File)
Mon, Apr 1, 4:07 PM
Unknown Object (File)
Mar 18 2024, 5:53 PM
Unknown Object (File)
Feb 12 2024, 9:19 AM
Unknown Object (File)
Feb 11 2024, 12:59 PM
Subscribers

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Maniphest Tasks
T7480: Allow editing the name of a file
Commits
Restricted Diffusion Commit
rP55ff197f2a89: File names should be editable.
Summary

Fixes T7480, File names should be editable and the event should show up in feed.

Test Plan

Upload a file, view file details, edit file, change file name by adding a space and a word to the name, save changes, file name should retain space and not normalize the name, file details should show the edit event, install feed should correctly show an event for the action.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lpriestley retitled this revision from to File names should be editable..
lpriestley updated this object.
lpriestley edited the test plan for this revision. (Show Details)
lpriestley added a reviewer: epriestley.
lpriestley edited edge metadata.

Cleaning up commented out code.

Preventing user from making file name blank.

epriestley edited edge metadata.

Couple of minor inlines.

We should prevent empty names, per discussion.

For questionable names which don't survive normalization, let's do this:

  • Overall, these steps will move us from unevenly normalizing inputs to never normalizing inputs and always normalizing outputs.
  • Remove the call to normalizeFileName() in PhabricatorFile->buildFromFileDataOrHash().
  • Remove the call to normalizeFileName() in PhabricatorFile->readPropertiesFromParameters().
  • Add a call to normalizeFileName() in PhabricatorFile->getCDNURI().

This will let files have silly names within Phabricator, but make sure we can generate working URIs even if the name is a creative one.

src/applications/files/storage/PhabricatorFileTransaction.php
29

It's a little more conventional to just put the strings in this transaction description, like:

return pht(
  '%s updated the name for this file from "%s" to "%s".',
  $this->renderHandleLink($author_phid),
  $old,
  $new);

Then remove hasChangeDetails() and renderChangeDetails(). This will just show the change in the transaction instead of requiring a click.

The click workflow is used elsewhere for fields which may contain a lot of text, like a description or document, so we can't just embed the entire change in the transaction.

48

Just dump the names in here too.

This revision now requires changes to proceed.Apr 26 2015, 9:30 PM

Empty name checking code is all good.

lpriestley edited edge metadata.

Normalizing on download, not upload (supposedly), and updated transaction titles.

epriestley edited edge metadata.
epriestley added inline comments.
src/applications/files/storage/PhabricatorFile.php
212

This should still be idx($params, 'name'), -- just no normalizeFileName() call.

696

Do this first, before escaping.

This revision now requires changes to proceed.Apr 26 2015, 9:57 PM
src/applications/files/storage/PhabricatorFile.php
696

Tested this and it's not actually normalizing the name. Definitely missing something.

lpriestley edited edge metadata.

Normalizing file name properly.

lpriestley edited edge metadata.

Normalize, then escape name.

epriestley edited edge metadata.
epriestley added inline comments.
src/applications/files/storage/PhabricatorFile.php
695

$name isn't declared here yet, so PHP fatals:

Undefined variable: name

This revision now requires changes to proceed.Apr 26 2015, 10:07 PM
epriestley edited edge metadata.
This revision is now accepted and ready to land.Apr 26 2015, 10:24 PM
This revision was automatically updated to reflect the committed changes.