@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve package resolution APIs on CelerityResourceMap

Summary:
Ref T4222. A few diffs from now, `CelerityResourceMap` will have a `CelerityResources` inside of it:

- Rename `resolvePackage()` to `getResourceNamesForPackageHash()`. This isn't a functional change, it's just making it clear what it does.
- Add `getResourceDataForName()`, to push details about storage into `CelerityResources`.

Test Plan: Reloaded a bunch of pages, rebuilt map.

Reviewers: btrahan, hach-que

Reviewed By: hach-que

CC: aran

Maniphest Tasks: T4222

Differential Revision: https://secure.phabricator.com/D7869

+14 -13
+7 -12
src/infrastructure/celerity/CelerityResourceController.php
··· 16 16 return false; 17 17 } 18 18 19 - private function getDiskPath($to_resource = null) { 20 - return $this->getRootDirectory().$to_resource; 21 - } 22 - 23 19 protected function serveResource($path, $package_hash = null) { 24 20 // Sanity checking to keep this from exposing anything sensitive, since it 25 21 // ultimately boils down to disk reads. ··· 41 37 return $this->makeResponseCacheable(new Aphront304Response()); 42 38 } 43 39 40 + $map = CelerityResourceMap::getInstance(); 41 + 44 42 if ($package_hash) { 45 - $map = CelerityResourceMap::getInstance(); 46 - $paths = $map->resolvePackage($package_hash); 47 - if (!$paths) { 43 + $resource_names = $map->getResourceNamesForPackageHash($package_hash); 44 + if (!$resource_names) { 48 45 return new Aphront404Response(); 49 46 } 50 47 51 48 try { 52 49 $data = array(); 53 - foreach ($paths as $package_path) { 54 - $disk_path = $this->getDiskPath($package_path); 55 - $data[] = Filesystem::readFile($disk_path); 50 + foreach ($resource_names as $resource_name) { 51 + $data[] = $map->getResourceDataForName($resource_name); 56 52 } 57 53 $data = implode("\n\n", $data); 58 54 } catch (Exception $ex) { ··· 60 56 } 61 57 } else { 62 58 try { 63 - $disk_path = $this->getDiskPath($path); 64 - $data = Filesystem::readFile($disk_path); 59 + $data = $map->getResourceDataForName($path); 65 60 } catch (Exception $ex) { 66 61 return new Aphront404Response(); 67 62 }
+7 -1
src/infrastructure/celerity/CelerityResourceMap.php
··· 90 90 return $packaged; 91 91 } 92 92 93 - public function resolvePackage($package_hash) { 93 + public function getResourceDataForName($resource_name) { 94 + $root = phutil_get_library_root('phabricator'); 95 + $root = dirname($root).'/webroot/'; 96 + return Filesystem::readFile($root.$resource_name); 97 + } 98 + 99 + public function getResourceNamesForPackageHash($package_hash) { 94 100 $package = idx($this->packageMap['packages'], $package_hash); 95 101 if (!$package) { 96 102 return null;