Index: branches/REL1_18/phase3/includes/parser/ParserOutput.php |
— | — | @@ -396,11 +396,11 @@ |
397 | 397 | /** |
398 | 398 | * Returns the options from its ParserOptions which have been taken |
399 | 399 | * into account to produce this output or false if not available. |
400 | | - * @return mixed Array/false |
| 400 | + * @return mixed Array |
401 | 401 | */ |
402 | 402 | public function getUsedOptions() { |
403 | 403 | if ( !isset( $this->mAccessedOptions ) ) { |
404 | | - return false; |
| 404 | + return array(); |
405 | 405 | } |
406 | 406 | return array_keys( $this->mAccessedOptions ); |
407 | 407 | } |
Index: branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -473,17 +473,31 @@ |
474 | 474 | try { |
475 | 475 | $scripts = ''; |
476 | 476 | if ( $context->shouldIncludeScripts() ) { |
477 | | - $scripts = $module->getScript( $context ); |
478 | | - if ( is_string( $scripts ) ) { |
479 | | - // bug 27054: Append semicolon to prevent weird bugs |
480 | | - // caused by files not terminating their statements right |
481 | | - $scripts .= ";\n"; |
| 477 | + // If we are in debug mode, we'll want to return an array of URLs if possible |
| 478 | + // However, we can't do this if the module doesn't support it |
| 479 | + // We also can't do this if there is an only= parameter, because we have to give |
| 480 | + // the module a way to return a load.php URL without causing an infinite loop |
| 481 | + if ( $context->getDebug() && !$context->getOnly() && $module->supportsURLLoading() ) { |
| 482 | + $scripts = $module->getScriptURLsForDebug( $context ); |
| 483 | + } else { |
| 484 | + $scripts = $module->getScript( $context ); |
| 485 | + if ( is_string( $scripts ) ) { |
| 486 | + // bug 27054: Append semicolon to prevent weird bugs |
| 487 | + // caused by files not terminating their statements right |
| 488 | + $scripts .= ";\n"; |
| 489 | + } |
482 | 490 | } |
483 | 491 | } |
484 | 492 | // Styles |
485 | 493 | $styles = array(); |
486 | 494 | if ( $context->shouldIncludeStyles() ) { |
487 | | - $styles = $module->getStyles( $context ); |
| 495 | + // If we are in debug mode, we'll want to return an array of URLs |
| 496 | + // See comment near shouldIncludeScripts() for more details |
| 497 | + if ( $context->getDebug() && !$context->getOnly() && $module->supportsURLLoading() ) { |
| 498 | + $styles = $module->getStyleURLsForDebug( $context ); |
| 499 | + } else { |
| 500 | + $styles = $module->getStyles( $context ); |
| 501 | + } |
488 | 502 | } |
489 | 503 | |
490 | 504 | // Messages |
Property changes on: branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
491 | 505 | Merged /trunk/phase3/includes/resourceloader/ResourceLoader.php:r93626,96562,96640,96978,97050 |
Index: branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderFileModule.php |
— | — | @@ -217,16 +217,21 @@ |
218 | 218 | */ |
219 | 219 | public function getScript( ResourceLoaderContext $context ) { |
220 | 220 | $files = $this->getScriptFiles( $context ); |
221 | | - if ( $context->getDebug() && $this->debugRaw ) { |
222 | | - $urls = array(); |
223 | | - foreach ( $this->getScriptFiles( $context ) as $file ) { |
224 | | - $urls[] = $this->getRemotePath( $file ); |
225 | | - } |
226 | | - return $urls; |
227 | | - } |
228 | 221 | return $this->readScriptFiles( $files ); |
229 | 222 | } |
| 223 | + |
| 224 | + public function getScriptURLsForDebug( ResourceLoaderContext $context ) { |
| 225 | + $urls = array(); |
| 226 | + foreach ( $this->getScriptFiles( $context ) as $file ) { |
| 227 | + $urls[] = $this->getRemotePath( $file ); |
| 228 | + } |
| 229 | + return $urls; |
| 230 | + } |
230 | 231 | |
| 232 | + public function supportsURLLoading() { |
| 233 | + return $this->debugRaw; |
| 234 | + } |
| 235 | + |
231 | 236 | /** |
232 | 237 | * Gets loader script. |
233 | 238 | * |
— | — | @@ -250,16 +255,6 @@ |
251 | 256 | $this->getStyleFiles( $context ), |
252 | 257 | $this->getFlip( $context ) |
253 | 258 | ); |
254 | | - if ( !$context->getOnly() && $context->getDebug() && $this->debugRaw ) { |
255 | | - $urls = array(); |
256 | | - foreach ( $this->getStyleFiles( $context ) as $mediaType => $list ) { |
257 | | - $urls[$mediaType] = array(); |
258 | | - foreach ( $list as $file ) { |
259 | | - $urls[$mediaType][] = $this->getRemotePath( $file ); |
260 | | - } |
261 | | - } |
262 | | - return $urls; |
263 | | - } |
264 | 259 | // Collect referenced files |
265 | 260 | $this->localFileRefs = array_unique( $this->localFileRefs ); |
266 | 261 | // If the list has been modified since last time we cached it, update the cache |
— | — | @@ -276,6 +271,17 @@ |
277 | 272 | return $styles; |
278 | 273 | } |
279 | 274 | |
| 275 | + public function getStyleURLsForDebug( ResourceLoaderContext $context ) { |
| 276 | + $urls = array(); |
| 277 | + foreach ( $this->getStyleFiles( $context ) as $mediaType => $list ) { |
| 278 | + $urls[$mediaType] = array(); |
| 279 | + foreach ( $list as $file ) { |
| 280 | + $urls[$mediaType][] = $this->getRemotePath( $file ); |
| 281 | + } |
| 282 | + } |
| 283 | + return $urls; |
| 284 | + } |
| 285 | + |
280 | 286 | /** |
281 | 287 | * Gets list of message keys used by this module. |
282 | 288 | * |
Index: branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderModule.php |
— | — | @@ -126,6 +126,44 @@ |
127 | 127 | // Stub, override expected |
128 | 128 | return ''; |
129 | 129 | } |
| 130 | + |
| 131 | + /** |
| 132 | + * Get the URL or URLs to load for this module's JS in debug mode. |
| 133 | + * The default behavior is to return a load.php?only=scripts URL for |
| 134 | + * the module, but file-based modules will want to override this to |
| 135 | + * load the files directly. |
| 136 | + * |
| 137 | + * This function is called only when 1) we're in debug mode, 2) there |
| 138 | + * is no only= parameter and 3) supportsURLLoading() returns true. |
| 139 | + * #2 is important to prevent an infinite loop, therefore this function |
| 140 | + * MUST return either an only= URL or a non-load.php URL. |
| 141 | + * |
| 142 | + * @param $context ResourceLoaderContext: Context object |
| 143 | + * @return Array of URLs |
| 144 | + */ |
| 145 | + public function getScriptURLsForDebug( ResourceLoaderContext $context ) { |
| 146 | + global $wgLoadScript; // TODO factor out to ResourceLoader static method and deduplicate from makeResourceLoaderLink() |
| 147 | + $query = array( |
| 148 | + 'modules' => $this->getName(), |
| 149 | + 'only' => 'scripts', |
| 150 | + 'skin' => $context->getSkin(), |
| 151 | + 'user' => $context->getUser(), |
| 152 | + 'debug' => 'true', |
| 153 | + 'version' => $context->getVersion() |
| 154 | + ); |
| 155 | + ksort( $query ); |
| 156 | + return array( wfAppendQuery( $wgLoadScript, $query ) . '&*' ); |
| 157 | + } |
| 158 | + |
| 159 | + /** |
| 160 | + * Whether this module supports URL loading. If this function returns false, |
| 161 | + * getScript() will be used even in cases (debug mode, no only param) where |
| 162 | + * getScriptURLsForDebug() would normally be used instead. |
| 163 | + * @return bool |
| 164 | + */ |
| 165 | + public function supportsURLLoading() { |
| 166 | + return true; |
| 167 | + } |
130 | 168 | |
131 | 169 | /** |
132 | 170 | * Get all CSS for this module for a given skin. |
— | — | @@ -137,6 +175,29 @@ |
138 | 176 | // Stub, override expected |
139 | 177 | return array(); |
140 | 178 | } |
| 179 | + |
| 180 | + /** |
| 181 | + * Get the URL or URLs to load for this module's CSS in debug mode. |
| 182 | + * The default behavior is to return a load.php?only=styles URL for |
| 183 | + * the module, but file-based modules will want to override this to |
| 184 | + * load the files directly. See also getScriptURLsForDebug() |
| 185 | + * |
| 186 | + * @param $context ResourceLoaderContext: Context object |
| 187 | + * @return Array: array( mediaType => array( URL1, URL2, ... ), ... ) |
| 188 | + */ |
| 189 | + public function getStyleURLsForDebug( ResourceLoaderContext $context ) { |
| 190 | + global $wgLoadScript; // TODO factor out to ResourceLoader static method and deduplicate from makeResourceLoaderLink() |
| 191 | + $query = array( |
| 192 | + 'modules' => $this->getName(), |
| 193 | + 'only' => 'styles', |
| 194 | + 'skin' => $context->getSkin(), |
| 195 | + 'user' => $context->getUser(), |
| 196 | + 'debug' => 'true', |
| 197 | + 'version' => $context->getVersion() |
| 198 | + ); |
| 199 | + ksort( $query ); |
| 200 | + return array( 'all' => array( wfAppendQuery( $wgLoadScript, $query ) . '&*' ) ); |
| 201 | + } |
141 | 202 | |
142 | 203 | /** |
143 | 204 | * Get the messages needed for this module. |
Index: branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php |
— | — | @@ -69,10 +69,6 @@ |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | | - |
74 | | - $serverBits = wfParseUrl( $wgServer ); |
75 | | - $protocol = $serverBits ? $serverBits['scheme'] : 'http'; |
76 | | - |
77 | 73 | // Build list of variables |
78 | 74 | $vars = array( |
79 | 75 | 'wgLoadScript' => $wgLoadScript, |
— | — | @@ -108,7 +104,6 @@ |
109 | 105 | 'wgFileCanRotate' => BitmapHandler::canRotate(), |
110 | 106 | 'wgAvailableSkins' => Skin::getSkinNames(), |
111 | 107 | 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, |
112 | | - 'wgProto' => $protocol, |
113 | 108 | // MediaWiki sets cookies to have this prefix by default |
114 | 109 | 'wgCookiePrefix' => $wgCookiePrefix, |
115 | 110 | 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, |
— | — | @@ -234,6 +229,10 @@ |
235 | 230 | return $out; |
236 | 231 | } |
237 | 232 | |
| 233 | + public function supportsURLLoading() { |
| 234 | + return false; |
| 235 | + } |
| 236 | + |
238 | 237 | /** |
239 | 238 | * @param $context ResourceLoaderContext |
240 | 239 | * @return array|mixed |
Index: branches/REL1_18/phase3/includes/cache/MessageCache.php |
— | — | @@ -764,15 +764,23 @@ |
765 | 765 | $popts->setTargetLanguage( $language ); |
766 | 766 | } |
767 | 767 | |
| 768 | + wfProfileIn( __METHOD__ ); |
768 | 769 | if ( !$title || !$title instanceof Title ) { |
769 | 770 | global $wgTitle; |
770 | 771 | $title = $wgTitle; |
771 | 772 | } |
| 773 | + // Sometimes $wgTitle isn't set either... |
| 774 | + if ( !$title ) { |
| 775 | + # It's not uncommon having a null $wgTitle in scripts. See r80898 |
| 776 | + # Create a ghost title in such case |
| 777 | + $title = Title::newFromText( 'Dwimmerlaik' ); |
| 778 | + } |
772 | 779 | |
773 | 780 | $this->mInParser = true; |
774 | 781 | $res = $parser->parse( $text, $title, $popts, $linestart ); |
775 | 782 | $this->mInParser = false; |
776 | 783 | |
| 784 | + wfProfileOut( __METHOD__ ); |
777 | 785 | return $res; |
778 | 786 | } |
779 | 787 | |
Property changes on: branches/REL1_18/phase3/includes/cache/MessageCache.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
780 | 788 | Merged /trunk/phase3/includes/cache/MessageCache.php:r93626,96562,96640,96978,97050 |
Index: branches/REL1_18/phase3/includes/HttpFunctions.php |
— | — | @@ -32,7 +32,6 @@ |
33 | 33 | * @return Mixed: (bool)false on failure or a string on success |
34 | 34 | */ |
35 | 35 | public static function request( $method, $url, $options = array() ) { |
36 | | - $url = wfExpandUrl( $url, PROTO_HTTP ); |
37 | 36 | wfDebug( "HTTP: $method: $url\n" ); |
38 | 37 | $options['method'] = strtoupper( $method ); |
39 | 38 | |
— | — | @@ -178,14 +177,14 @@ |
179 | 178 | public $status; |
180 | 179 | |
181 | 180 | /** |
182 | | - * @param $url String: url to use |
| 181 | + * @param $url String: url to use. If protocol-relative, will be expanded to an http:// URL |
183 | 182 | * @param $options Array: (optional) extra params to pass (see Http::request()) |
184 | 183 | */ |
185 | 184 | function __construct( $url, $options = array() ) { |
186 | 185 | global $wgHTTPTimeout; |
187 | 186 | |
188 | | - $this->url = $url; |
189 | | - $this->parsedUrl = parse_url( $url ); |
| 187 | + $this->url = wfExpandUrl( $url, PROTO_HTTP ); |
| 188 | + $this->parsedUrl = parse_url( $this->url ); |
190 | 189 | |
191 | 190 | if ( !Http::isValidURI( $this->url ) ) { |
192 | 191 | $this->status = Status::newFatal( 'http-invalid-url' ); |