1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Kill PhabricatorFileURI

Summary:
we used to need this function for security purposes, but no longer need
it.   remove it so that some call sites can be optimized via smarter data
fetching, and so the whole codebase can have one less thing in it.

Test Plan:
verified the images displayed properly for each of the following
- viewed a diff with added images.
- viewed a user feed
- viewed a user profile
- viewed all image macros
- viewed a paste and clicked through "raw link"
weakness in testing around proxy files and transformed files.  not sure what
these are.  changes here are very programmatic however.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, btrahan, epriestley

Maniphest Tasks: T672

Differential Revision: https://secure.phabricator.com/D1354
This commit is contained in:
Bob Trahan 2012-01-10 14:48:55 -08:00
parent b9cac3bcd1
commit 84ea5c53e4
36 changed files with 122 additions and 133 deletions

View file

@ -475,7 +475,6 @@ phutil_register_library_map(array(
'PhabricatorFileStorageEngine' => 'applications/files/engine/base', 'PhabricatorFileStorageEngine' => 'applications/files/engine/base',
'PhabricatorFileStorageEngineSelector' => 'applications/files/engineselector/base', 'PhabricatorFileStorageEngineSelector' => 'applications/files/engineselector/base',
'PhabricatorFileTransformController' => 'applications/files/controller/transform', 'PhabricatorFileTransformController' => 'applications/files/controller/transform',
'PhabricatorFileURI' => 'applications/files/uri',
'PhabricatorFileUploadController' => 'applications/files/controller/upload', 'PhabricatorFileUploadController' => 'applications/files/controller/upload',
'PhabricatorFileUploadException' => 'applications/files/exception/upload', 'PhabricatorFileUploadException' => 'applications/files/exception/upload',
'PhabricatorFileUploadView' => 'applications/files/view/upload', 'PhabricatorFileUploadView' => 'applications/files/view/upload',

View file

@ -867,7 +867,6 @@ class DifferentialChangesetParser {
$range_len = null, $range_len = null,
$mask_force = array()) { $mask_force = array()) {
// "Top level" renders are initial requests for the whole file, versus // "Top level" renders are initial requests for the whole file, versus
// requests for a specific range generated by clicking "show more". We // requests for a specific range generated by clicking "show more". We
// generate property changes and "shield" UI elements only for toplevel // generate property changes and "shield" UI elements only for toplevel
@ -915,21 +914,37 @@ class DifferentialChangesetParser {
} }
if ($old_phid || $new_phid) { if ($old_phid || $new_phid) {
// grab the files, (micro) optimization for 1 query not 2
$file_phids = array();
if ($old_phid) { if ($old_phid) {
$old_uri = PhabricatorFileURI::getViewURIForPHID($old_phid); $file_phids[] = $old_phid;
$old = phutil_render_tag(
'img',
array(
'src' => $old_uri,
));
} }
if ($new_phid) { if ($new_phid) {
$new_uri = PhabricatorFileURI::getViewURIForPHID($new_phid); $file_phids[] = $new_phid;
$cur = phutil_render_tag( }
'img',
array( $files = id(new PhabricatorFile())->loadAllWhere(
'src' => $new_uri, 'phid IN (%Ls)',
)); $file_phids);
foreach ($files as $file) {
if (empty($file)) {
continue;
}
if ($file->getPHID() == $old_phid) {
$old = phutil_render_tag(
'img',
array(
'src' => $file->getBestURI(),
));
} else {
$cur = phutil_render_tag(
'img',
array(
'src' => $file->getBestURI(),
));
}
} }
} }

View file

@ -12,7 +12,7 @@ phutil_require_module('phabricator', 'aphront/writeguard');
phutil_require_module('phabricator', 'applications/differential/constants/changetype'); phutil_require_module('phabricator', 'applications/differential/constants/changetype');
phutil_require_module('phabricator', 'applications/differential/storage/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/changeset');
phutil_require_module('phabricator', 'applications/differential/view/inlinecomment'); phutil_require_module('phabricator', 'applications/differential/view/inlinecomment');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/markup/syntax'); phutil_require_module('phabricator', 'applications/markup/syntax');
phutil_require_module('phabricator', 'infrastructure/diff/engine'); phutil_require_module('phabricator', 'infrastructure/diff/engine');
phutil_require_module('phabricator', 'infrastructure/events/constant/type'); phutil_require_module('phabricator', 'infrastructure/events/constant/type');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -66,9 +66,8 @@ class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
} }
if ($full_size) { if ($full_size) {
if (!empty($objects[$author_phid])) { if (!empty($handles[$author_phid])) {
$image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = $handles[$author_phid]->getImageURI();
$image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid);
$view->setImage($image_uri); $view->setImage($image_uri);
} }

View file

@ -9,7 +9,6 @@
phutil_require_module('phabricator', 'applications/differential/constants/action'); phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'applications/feed/story/base'); phutil_require_module('phabricator', 'applications/feed/story/base');
phutil_require_module('phabricator', 'applications/feed/view/story'); phutil_require_module('phabricator', 'applications/feed/view/story');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,6 +42,7 @@ class PhabricatorFeedStoryManiphest extends PhabricatorFeedStory {
$task_phid = $data->getValue('taskPHID'); $task_phid = $data->getValue('taskPHID');
$objects = $this->getObjects(); $objects = $this->getObjects();
$handles = $this->getHandles();
$action = $data->getValue('action'); $action = $data->getValue('action');
$view = new PhabricatorFeedStoryView(); $view = new PhabricatorFeedStoryView();
@ -82,9 +83,8 @@ class PhabricatorFeedStoryManiphest extends PhabricatorFeedStory {
$view->setEpoch($data->getEpoch()); $view->setEpoch($data->getEpoch());
if ($full_size) { if ($full_size) {
if (!empty($objects[$author_phid])) { if (!empty($handles[$author_phid])) {
$image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = $handles[$author_phid]->getImageURI();
$image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid);
$view->setImage($image_uri); $view->setImage($image_uri);
} }

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'applications/feed/story/base'); phutil_require_module('phabricator', 'applications/feed/story/base');
phutil_require_module('phabricator', 'applications/feed/view/story'); phutil_require_module('phabricator', 'applications/feed/view/story');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/maniphest/constants/action'); phutil_require_module('phabricator', 'applications/maniphest/constants/action');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,9 +62,8 @@ class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
} }
if ($full_size) { if ($full_size) {
if (!empty($objects[$author_phid])) { if (!empty($handles[$author_phid])) {
$image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = $handles[$author_phid]->getImageURI();
$image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid);
$view->setImage($image_uri); $view->setImage($image_uri);
} }

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'applications/feed/story/base'); phutil_require_module('phabricator', 'applications/feed/story/base');
phutil_require_module('phabricator', 'applications/feed/view/story'); phutil_require_module('phabricator', 'applications/feed/view/story');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/phriction/constants/action'); phutil_require_module('phabricator', 'applications/phriction/constants/action');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,9 +44,8 @@ class PhabricatorFeedStoryStatus extends PhabricatorFeedStory {
'<strong>'.$handles[$author_phid]->renderLink().'</strong>'); '<strong>'.$handles[$author_phid]->renderLink().'</strong>');
$view->setEpoch($data->getEpoch()); $view->setEpoch($data->getEpoch());
if (!empty($objects[$author_phid])) { if (!empty($handles[$author_phid])) {
$image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = $handles[$author_phid]->getImageURI();
$image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid);
$view->setImage($image_uri); $view->setImage($image_uri);
} }

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'applications/feed/story/base'); phutil_require_module('phabricator', 'applications/feed/story/base');
phutil_require_module('phabricator', 'applications/feed/view/story'); phutil_require_module('phabricator', 'applications/feed/view/story');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,11 +52,12 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
$handles = id(new PhabricatorObjectHandleData($author_phids)) $handles = id(new PhabricatorObjectHandleData($author_phids))
->loadHandles(); ->loadHandles();
} }
$files_map = mpull($files, null, 'getPHID');
$rows = array(); $rows = array();
foreach ($macros as $macro) { foreach ($macros as $macro) {
$src = PhabricatorFileURI::getViewURIForPHID($macro->getFilePHID());
$file_phid = $macro->getFilePHID(); $file_phid = $macro->getFilePHID();
$file = $files_map[$file_phid];
$author_link = isset($author_phids[$file_phid]) $author_link = isset($author_phids[$file_phid])
? $handles[$author_phids[$file_phid]]->renderLink() ? $handles[$author_phids[$file_phid]]->renderLink()
: null; : null;
@ -73,13 +74,13 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
phutil_render_tag( phutil_render_tag(
'a', 'a',
array( array(
'href' => $src, 'href' => $file->getBestURI(),
'target' => '_blank', 'target' => '_blank',
), ),
phutil_render_tag( phutil_render_tag(
'img', 'img',
array( array(
'src' => $src, 'src' => $file->getBestURI(),
))), ))),
javelin_render_tag( javelin_render_tag(
'a', 'a',

View file

@ -9,7 +9,6 @@
phutil_require_module('phabricator', 'applications/files/controller/base'); phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/storage/imagemacro'); phutil_require_module('phabricator', 'applications/files/storage/imagemacro');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/files/view/sidenav'); phutil_require_module('phabricator', 'applications/files/view/sidenav');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'infrastructure/javelin/markup');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,7 +52,16 @@ class PhabricatorFileProxyController extends PhabricatorFileController {
} }
if ($proxy) { if ($proxy) {
$view_uri = PhabricatorFileURI::getViewURIForPHID($proxy->getFilePHID()); $file = id(new PhabricatorFile())->loadOneWhere('phid = %s',
$proxy->getFilePHID());
if ($file) {
$view_uri = $file->getBestURI();
} else {
$bad_phid = $proxy->getFilePHID();
throw new Exception(
"Unable to load file with phid {$bad_phid}."
);
}
return id(new AphrontRedirectResponse())->setURI($view_uri); return id(new AphrontRedirectResponse())->setURI($view_uri);
} }

View file

@ -12,7 +12,6 @@ phutil_require_module('phabricator', 'aphront/writeguard');
phutil_require_module('phabricator', 'applications/files/controller/base'); phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/storage/proxyimage'); phutil_require_module('phabricator', 'applications/files/storage/proxyimage');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -113,10 +113,21 @@ class PhabricatorFileTransformController extends PhabricatorFileController {
private function buildTransformedFileResponse( private function buildTransformedFileResponse(
PhabricatorTransformedFile $xform) { PhabricatorTransformedFile $xform) {
$file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$xform->getTransformedPHID());
if ($file) {
$uri = $file->getBestURI();
} else {
$bad_phid = $xform->getTransformedPHID();
throw new Exception(
"Unable to load file with phid {$bad_phid}."
);
}
// TODO: We could just delegate to the file view controller instead, // TODO: We could just delegate to the file view controller instead,
// which would save the client a roundtrip, but is slightly more complex. // which would save the client a roundtrip, but is slightly more complex.
return id(new AphrontRedirectResponse())->setURI( return id(new AphrontRedirectResponse())->setURI($uri);
PhabricatorFileURI::getViewURIForPHID($xform->getTransformedPHID()));
} }
private function executeThumbTransform(PhabricatorFile $file, $x, $y) { private function executeThumbTransform(PhabricatorFile $file, $x, $y) {

View file

@ -14,7 +14,6 @@ phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/storage/transformed'); phutil_require_module('phabricator', 'applications/files/storage/transformed');
phutil_require_module('phabricator', 'applications/files/transform'); phutil_require_module('phabricator', 'applications/files/transform');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -184,6 +184,11 @@ class PhabricatorFileViewController extends PhabricatorFileController {
$transformations = id(new PhabricatorTransformedFile())->loadAllWhere( $transformations = id(new PhabricatorTransformedFile())->loadAllWhere(
'originalPHID = %s', 'originalPHID = %s',
$file->getPHID()); $file->getPHID());
$transformed_phids = mpull($transformations, 'getTransformedPHID');
$transformed_files = id(new PhabricatorFile())->loadAllWhere(
'phid in (%Ls)',
$transformed_phids);
$transformed_map = mpull($transformed_files, null, 'getPHID');
$rows = array(); $rows = array();
foreach ($transformations as $transformed) { foreach ($transformations as $transformed) {
$phid = $transformed->getTransformedPHID(); $phid = $transformed->getTransformedPHID();
@ -192,7 +197,7 @@ class PhabricatorFileViewController extends PhabricatorFileController {
phutil_render_tag( phutil_render_tag(
'a', 'a',
array( array(
'href' => PhabricatorFileURI::getViewURIForPHID($phid), 'href' => $transformed_map[$phid]->getBestURI(),
), ),
$phid)); $phid));
} }

View file

@ -13,7 +13,6 @@ phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/files/controller/base'); phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/storage/transformed'); phutil_require_module('phabricator', 'applications/files/storage/transformed');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');

View file

@ -1,36 +0,0 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorFileURI {
public static function getViewURIForPHID($phid) {
// TODO: Get rid of this class, the advent of the applet attack makes the
// tiny optimization it represented effectively obsolete.
$file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$phid);
if ($file) {
return $file->getViewURI();
}
return null;
}
}

View file

@ -1,14 +0,0 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorFileURI.php');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
), ),
'Fork This')); 'Fork This'));
$raw_uri = PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID()); $raw_uri = $file->getBestURI();
$paste_panel->addButton( $paste_panel->addButton(
phutil_render_tag( phutil_render_tag(
'a', 'a',

View file

@ -9,7 +9,6 @@
phutil_require_module('phabricator', 'aphront/response/400'); phutil_require_module('phabricator', 'aphront/response/400');
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/markup/syntax'); phutil_require_module('phabricator', 'applications/markup/syntax');
phutil_require_module('phabricator', 'applications/paste/controller/base'); phutil_require_module('phabricator', 'applications/paste/controller/base');
phutil_require_module('phabricator', 'applications/paste/storage/paste'); phutil_require_module('phabricator', 'applications/paste/storage/paste');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -115,7 +115,12 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
} }
$src_phid = $user->getProfileImagePHID(); $src_phid = $user->getProfileImagePHID();
$picture = PhabricatorFileURI::getViewURIForPHID($src_phid); $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
if ($file) {
$picture = $file->getBestURI();
} else {
$picture = null;
}
$header = new PhabricatorProfileHeaderView(); $header = new PhabricatorProfileHeaderView();
$header $header

View file

@ -10,7 +10,7 @@ phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/auth/oauth/provider/base'); phutil_require_module('phabricator', 'applications/auth/oauth/provider/base');
phutil_require_module('phabricator', 'applications/feed/builder/feed'); phutil_require_module('phabricator', 'applications/feed/builder/feed');
phutil_require_module('phabricator', 'applications/feed/query'); phutil_require_module('phabricator', 'applications/feed/query');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/people/controller/base'); phutil_require_module('phabricator', 'applications/people/controller/base');
phutil_require_module('phabricator', 'applications/people/storage/profile'); phutil_require_module('phabricator', 'applications/people/storage/profile');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -96,8 +96,14 @@ class PhabricatorUserProfileSettingsPanelController
} }
} }
$img_src = PhabricatorFileURI::getViewURIForPHID( $file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$user->getProfileImagePHID()); $user->getProfileImagePHID());
if ($file) {
$img_src = $file->getBestURI();
} else {
$img_src = null;
}
$profile_uri = PhabricatorEnv::getURI('/p/'.$user->getUsername().'/'); $profile_uri = PhabricatorEnv::getURI('/p/'.$user->getUsername().'/');
$form = new AphrontFormView(); $form = new AphrontFormView();

View file

@ -9,7 +9,6 @@
phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/files/storage/file'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/transform'); phutil_require_module('phabricator', 'applications/files/transform');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/people/controller/settings/panels/base'); phutil_require_module('phabricator', 'applications/people/controller/settings/panels/base');
phutil_require_module('phabricator', 'applications/people/storage/profile'); phutil_require_module('phabricator', 'applications/people/storage/profile');
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');

View file

@ -140,7 +140,7 @@ class PhabricatorObjectHandleData {
$images = id(new PhabricatorFile())->loadAllWhere( $images = id(new PhabricatorFile())->loadAllWhere(
'phid IN (%Ls)', 'phid IN (%Ls)',
$image_phids); $image_phids);
$images = mpull($images, 'getViewURI', 'getPHID'); $images = mpull($images, 'getBestURI', 'getPHID');
} }
foreach ($phids as $phid) { foreach ($phids as $phid) {

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,7 +44,15 @@ class PhabricatorProjectProfileController
if (!$src_phid) { if (!$src_phid) {
$src_phid = $user->getProfileImagePHID(); $src_phid = $user->getProfileImagePHID();
} }
$picture = PhabricatorFileURI::getViewURIForPHID($src_phid); $file = id(new PhabricatorFile())->loadOneWhere('phid = %s',
$src_phid);
if ($file) {
$picture = $file->getBestURI();
} else {
$picture = null;
}
$nav_view = new AphrontSideNavFilterView(); $nav_view = new AphrontSideNavFilterView();
$uri = new PhutilURI('/project/view/'.$project->getID().'/'); $uri = new PhutilURI('/project/view/'.$project->getID().'/');

View file

@ -9,7 +9,7 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/feed/builder/feed'); phutil_require_module('phabricator', 'applications/feed/builder/feed');
phutil_require_module('phabricator', 'applications/feed/query'); phutil_require_module('phabricator', 'applications/feed/query');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/maniphest/query'); phutil_require_module('phabricator', 'applications/maniphest/query');
phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary'); phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,17 +54,7 @@ final class PhabricatorSearchResultView extends AphrontView {
), ),
PhabricatorEnv::getProductionURI($handle->getURI())); PhabricatorEnv::getProductionURI($handle->getURI()));
switch ($handle->getType()) { $img = $handle->getImageURI();
case PhabricatorPHIDConstants::PHID_TYPE_USER:
if ($this->object) {
$img_phid = $this->object->getProfileImagePHID();
$img = PhabricatorFileURI::getViewURIForPHID($img_phid);
}
break;
default:
$img = null;
break;
}
if ($img) { if ($img) {
$img = phutil_render_tag( $img = phutil_render_tag(

View file

@ -6,7 +6,6 @@
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -403,8 +403,7 @@ class PhabricatorSlowvotePollController
continue; continue;
} }
$profile_image = PhabricatorFileURI::getViewURIForPHID( $profile_image = $handle->getImageURI();
$object->getProfileImagePHID());
$user_markup[] = phutil_render_tag( $user_markup[] = phutil_render_tag(
'a', 'a',

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/markup/engine'); phutil_require_module('phabricator', 'applications/markup/engine');
phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/slowvote/controller/base'); phutil_require_module('phabricator', 'applications/slowvote/controller/base');

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -69,11 +69,17 @@ class PhabricatorRemarkupRuleImageMacro
$phid = $this->images[$matches[1]]; $phid = $this->images[$matches[1]];
} }
$file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $phid);
if ($file) {
$src_uri = $file->getBestURI();
} else {
$src_uri = null;
}
$img = phutil_render_tag( $img = phutil_render_tag(
'img', 'img',
array( array(
'src' => PhabricatorFileURI::getViewURIForPHID($phid), 'src' => $src_uri,
'alt' => $matches[1], 'alt' => $matches[1],
'title' => $matches[1]), 'title' => $matches[1]),
null); null);

View file

@ -6,8 +6,8 @@
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/storage/imagemacro'); phutil_require_module('phabricator', 'applications/files/storage/imagemacro');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/base'); phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/base');