Make most file reads policy-aware

Summary: Ref T603. Swaps out most `PhabricatorFile` loads for `PhabricatorFileQuery`.

Test Plan:
  - Viewed Differential changesets.
  - Used `file.info`.
  - Used `file.download`.
  - Viewed a file.
  - Deleted a file.
  - Used `/Fnnnn` to access a file.
  - Uploaded an image, verified a thumbnail generated.
  - Created and edited a macro.
  - Added a meme.
  - Did old-school attach-a-file-to-a-task.
  - Viewed a paste.
  - Viewed a mock.
  - Embedded a mock.
  - Profiled a page.
  - Parsed a commit with image files linked to a revision with image files.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D7178
This commit is contained in:
epriestley
2013-09-30 09:38:13 -07:00
parent 4b39cc321b
commit 13dae05193
28 changed files with 124 additions and 67 deletions

View File

@@ -38,10 +38,15 @@ final class PhabricatorMacroMemeController
$file->getPHID(), $hash);
if ($xform) {
$memefile = id(new PhabricatorFile())->loadOneWhere(
'phid = %s', $xform->getTransformedPHID());
return $memefile->getBestURI();
$memefile = id(new PhabricatorFileQuery())
->setViewer($user)
->withPHIDs(array($xform->getTransformedPHID()))
->executeOne();
if ($memefile) {
return $memefile->getBestURI();
}
}
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$transformers = (new PhabricatorImageTransformer());
$newfile = $transformers