@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.

Make lookupSymbolInformation() a private API on CelerityResourceMap

Summary: Ref T4222. Same deal as D7867, but for this other super nebulous "return a blob of stuff" method.

Test Plan: Regenerated map, browsed around, etc.

Reviewers: btrahan, hach-que

Reviewed By: hach-que

CC: aran

Maniphest Tasks: T4222

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

+64 -14
+3 -2
src/applications/phame/skins/PhameBasicTemplateBlogSkin.php
··· 30 30 } 31 31 32 32 $map = CelerityResourceMap::getInstance(); 33 - $symbol_info = $map->lookupSymbolInformation('syntax-highlighting-css'); 33 + $resource_symbol = 'syntax-highlighting-css'; 34 + $resource_uri = $map->getFullyQualifiedURIForSymbol($resource_symbol); 34 35 35 36 $this->cssResources[] = phutil_tag( 36 37 'link', 37 38 array( 38 39 'rel' => 'stylesheet', 39 40 'type' => 'text/css', 40 - 'href' => PhabricatorEnv::getCDNURI($symbol_info['uri']), 41 + 'href' => $resource_uri, 41 42 )); 42 43 43 44 $this->cssResources = phutil_implode_html("\n", $this->cssResources);
+53 -3
src/infrastructure/celerity/CelerityResourceMap.php
··· 104 104 return $paths; 105 105 } 106 106 107 - public function lookupSymbolInformation($symbol) { 107 + private function lookupSymbolInformation($symbol) { 108 108 return idx($this->resourceMap, $symbol); 109 109 } 110 110 ··· 121 121 122 122 123 123 /** 124 + * Get the epoch timestamp of the last modification time of a symbol. 125 + * 126 + * @param string Resource symbol to lookup. 127 + * @return int Epoch timestamp of last resource modification. 128 + */ 129 + public function getModifiedTimeForSymbol($symbol) { 130 + $info = $this->lookupSymbolInformation($symbol); 131 + if ($info) { 132 + $root = dirname(phutil_get_library_root('phabricator')).'/webroot'; 133 + return (int)filemtime($root.$info['disk']); 134 + } 135 + return 0; 136 + } 137 + 138 + 139 + /** 140 + * Return the fully-qualified, absolute URI for the resource associated with 141 + * a symbol. This method is fairly low-level and ignores packaging. 142 + * 143 + * @param string Resource symbol to lookup. 144 + * @return string|null Fully-qualified resource URI, or null if the symbol 145 + * is unknown. 146 + */ 147 + public function getFullyQualifiedURIForSymbol($symbol) { 148 + $info = $this->lookupSymbolInformation($symbol); 149 + if ($info) { 150 + return idx($info, 'uri'); 151 + } 152 + return null; 153 + } 154 + 155 + 156 + /** 124 157 * Return the fully-qualified, absolute URI for the resource associated with 125 158 * a resource name. This method is fairly low-level and ignores packaging. 126 159 * 127 160 * @param string Resource name to lookup. 128 - * @return string Fully-qualified resource URI. 161 + * @return string|null Fully-qualified resource URI, or null if the name 162 + * is unknown. 129 163 */ 130 164 public function getFullyQualifiedURIForName($name) { 131 165 $info = $this->lookupFileInformation($name); ··· 140 174 * Return the resource symbols required by a named resource. 141 175 * 142 176 * @param string Resource name to lookup. 143 - * @return list<string> List of required symbols. 177 + * @return list<string>|null List of required symbols, or null if the name 178 + * is unknown. 144 179 */ 145 180 public function getRequiredSymbolsForName($name) { 146 181 $info = $this->lookupFileInformation($name); 147 182 if ($info) { 148 183 return idx($info, 'requires', array()); 184 + } 185 + return null; 186 + } 187 + 188 + 189 + /** 190 + * Return the resource name for a given symbol. 191 + * 192 + * @param string Resource symbol to lookup. 193 + * @return string|null Resource name, or null if the symbol is unknown. 194 + */ 195 + public function getResourceNameForSymbol($symbol) { 196 + $info = $this->lookupSymbolInformation($symbol); 197 + if ($info) { 198 + return idx($info, 'disk'); 149 199 } 150 200 return null; 151 201 }
+1 -2
src/infrastructure/celerity/CelerityStaticResourceResponse.php
··· 249 249 $mtime = 0; 250 250 foreach ($resource['symbols'] as $symbol) { 251 251 $map = CelerityResourceMap::getInstance(); 252 - $symbol_info = $map->lookupSymbolInformation($symbol); 253 - $mtime = max($mtime, (int)filemtime($root.$symbol_info['disk'])); 252 + $mtime = max($mtime, $map->getModifiedTimeForSymbol($symbol)); 254 253 } 255 254 } 256 255
+7 -7
src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
··· 153 153 $requires = array(); 154 154 } 155 155 156 - foreach ($requires as $key => $symbol_name) { 157 - $symbol_info = $celerity->lookupSymbolInformation($symbol_name); 158 - if (!$symbol_info) { 156 + foreach ($requires as $key => $requires_symbol) { 157 + $requires_name = $celerity->getResourceNameForSymbol($requires_symbol); 158 + if ($requires_name === null) { 159 159 $this->raiseLintAtLine( 160 160 0, 161 161 0, 162 162 self::LINT_UNKNOWN_DEPENDENCY, 163 - "This file @requires component '{$symbol_name}', but it does not ". 164 - "exist. You may need to rebuild the Celerity map."); 163 + "This file @requires component '{$requires_symbol}', but it does ". 164 + "not exist. You may need to rebuild the Celerity map."); 165 165 unset($requires[$key]); 166 166 continue; 167 167 } 168 168 169 - if (preg_match('/\\.css$/', $symbol_info['disk'])) { 169 + if (preg_match('/\\.css$/', $requires_name)) { 170 170 // If JS requires CSS, just assume everything is fine. 171 171 unset($requires[$key]); 172 172 } else { 173 - $symbol_path = 'webroot'.$symbol_info['disk']; 173 + $symbol_path = 'webroot'.$requires_name; 174 174 list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath( 175 175 $symbol_path); 176 176 if (array_intersect_key($req_install, $external_classes)) {