http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97263

Revision: 97263
Author:   reedy
Date:     2011-09-16 13:19:04 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
REL1_18 MFT r93626, r96562, r96640, r96978, r97050

Modified Paths:
--------------
    branches/REL1_18/phase3/includes/HttpFunctions.php
    branches/REL1_18/phase3/includes/cache/MessageCache.php
    branches/REL1_18/phase3/includes/parser/ParserOutput.php
    branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php
    branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderFileModule.php
    branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderModule.php
    
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php

Property Changed:
----------------
    branches/REL1_18/phase3/includes/cache/MessageCache.php
    branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php

Modified: branches/REL1_18/phase3/includes/HttpFunctions.php
===================================================================
--- branches/REL1_18/phase3/includes/HttpFunctions.php  2011-09-16 13:18:40 UTC 
(rev 97262)
+++ branches/REL1_18/phase3/includes/HttpFunctions.php  2011-09-16 13:19:04 UTC 
(rev 97263)
@@ -32,7 +32,6 @@
         * @return Mixed: (bool)false on failure or a string on success
         */
        public static function request( $method, $url, $options = array() ) {
-               $url = wfExpandUrl( $url, PROTO_HTTP );
                wfDebug( "HTTP: $method: $url\n" );
                $options['method'] = strtoupper( $method );
 
@@ -178,14 +177,14 @@
        public $status;
 
        /**
-        * @param $url String: url to use
+        * @param $url String: url to use. If protocol-relative, will be 
expanded to an http:// URL
         * @param $options Array: (optional) extra params to pass (see 
Http::request())
         */
        function __construct( $url, $options = array() ) {
                global $wgHTTPTimeout;
 
-               $this->url = $url;
-               $this->parsedUrl = parse_url( $url );
+               $this->url = wfExpandUrl( $url, PROTO_HTTP );
+               $this->parsedUrl = parse_url( $this->url );
 
                if ( !Http::isValidURI( $this->url ) ) {
                        $this->status = Status::newFatal( 'http-invalid-url' );

Modified: branches/REL1_18/phase3/includes/cache/MessageCache.php
===================================================================
--- branches/REL1_18/phase3/includes/cache/MessageCache.php     2011-09-16 
13:18:40 UTC (rev 97262)
+++ branches/REL1_18/phase3/includes/cache/MessageCache.php     2011-09-16 
13:19:04 UTC (rev 97263)
@@ -764,15 +764,23 @@
                        $popts->setTargetLanguage( $language );
                }
 
+               wfProfileIn( __METHOD__ );
                if ( !$title || !$title instanceof Title ) {
                        global $wgTitle;
                        $title = $wgTitle;
                }
+               // Sometimes $wgTitle isn't set either...
+               if ( !$title ) {
+                       # It's not uncommon having a null $wgTitle in scripts. 
See r80898
+                       # Create a ghost title in such case
+                       $title = Title::newFromText( 'Dwimmerlaik' );
+               }
 
                $this->mInParser = true;
                $res = $parser->parse( $text, $title, $popts, $linestart );
                $this->mInParser = false;
 
+               wfProfileOut( __METHOD__ );
                return $res;
        }
 


Property changes on: branches/REL1_18/phase3/includes/cache/MessageCache.php
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/REL1_15/phase3/includes/cache/MessageCache.php:51646
/branches/REL1_17/phase3/includes/MessageCache.php:81444
/branches/REL1_17/phase3/includes/cache/MessageCache.php:81444
/branches/new-installer/phase3/includes/cache/MessageCache.php:43664-66004
/branches/sqlite/includes/cache/MessageCache.php:58211-58321
/branches/wmf-deployment/includes/cache/MessageCache.php:53381
/trunk/phase3/includes/cache/MessageCache.php:92580,92713,92765,92884,92886-92887,92894,92898,92907,92932,93149,93151,93233-93234,93258,93266,93516-93518,93818-93822,93847,93858,93891,93935-93936,94068,94155,94235,94346,94372,94422,94425,94444,94448,94456,94498,94601,94728,94825,94862,94995-94997
   + /branches/REL1_15/phase3/includes/cache/MessageCache.php:51646
/branches/REL1_17/phase3/includes/MessageCache.php:81444
/branches/REL1_17/phase3/includes/cache/MessageCache.php:81444
/branches/new-installer/phase3/includes/cache/MessageCache.php:43664-66004
/branches/sqlite/includes/cache/MessageCache.php:58211-58321
/branches/wmf-deployment/includes/cache/MessageCache.php:53381
/trunk/phase3/includes/cache/MessageCache.php:92580,92713,92765,92884,92886-92887,92894,92898,92907,92932,93149,93151,93233-93234,93258,93266,93516-93518,93626,93818-93822,93847,93858,93891,93935-93936,94068,94155,94235,94346,94372,94422,94425,94444,94448,94456,94498,94601,94728,94825,94862,94995-94997,96562,96640,96978,97050

Modified: branches/REL1_18/phase3/includes/parser/ParserOutput.php
===================================================================
--- branches/REL1_18/phase3/includes/parser/ParserOutput.php    2011-09-16 
13:18:40 UTC (rev 97262)
+++ branches/REL1_18/phase3/includes/parser/ParserOutput.php    2011-09-16 
13:19:04 UTC (rev 97263)
@@ -396,11 +396,11 @@
        /**
         * Returns the options from its ParserOptions which have been taken 
         * into account to produce this output or false if not available.
-        * @return mixed Array/false
+        * @return mixed Array
         */
         public function getUsedOptions() {
                if ( !isset( $this->mAccessedOptions ) ) {
-                       return false;
+                       return array();
                }
                return array_keys( $this->mAccessedOptions );
         }

Modified: branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php
===================================================================
--- branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php  
2011-09-16 13:18:40 UTC (rev 97262)
+++ branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php  
2011-09-16 13:19:04 UTC (rev 97263)
@@ -473,17 +473,31 @@
                        try {
                                $scripts = '';
                                if ( $context->shouldIncludeScripts() ) {
-                                       $scripts = $module->getScript( $context 
);
-                                       if ( is_string( $scripts ) ) {
-                                               // bug 27054: Append semicolon 
to prevent weird bugs
-                                               // caused by files not 
terminating their statements right
-                                               $scripts .= ";\n";
+                                       // If we are in debug mode, we'll want 
to return an array of URLs if possible
+                                       // However, we can't do this if the 
module doesn't support it
+                                       // We also can't do this if there is an 
only= parameter, because we have to give
+                                       // the module a way to return a 
load.php URL without causing an infinite loop
+                                       if ( $context->getDebug() && 
!$context->getOnly() && $module->supportsURLLoading() ) {
+                                               $scripts = 
$module->getScriptURLsForDebug( $context );
+                                       } else {
+                                               $scripts = $module->getScript( 
$context );
+                                               if ( is_string( $scripts ) ) {
+                                                       // bug 27054: Append 
semicolon to prevent weird bugs
+                                                       // caused by files not 
terminating their statements right
+                                                       $scripts .= ";\n";
+                                               }
                                        }
                                }
                                // Styles
                                $styles = array();
                                if ( $context->shouldIncludeStyles() ) {
-                                       $styles = $module->getStyles( $context 
);
+                                       // If we are in debug mode, we'll want 
to return an array of URLs
+                                       // See comment near 
shouldIncludeScripts() for more details
+                                       if ( $context->getDebug() && 
!$context->getOnly() && $module->supportsURLLoading() ) {
+                                               $styles = 
$module->getStyleURLsForDebug( $context );
+                                       } else {
+                                               $styles = $module->getStyles( 
$context );
+                                       }
                                }
 
                                // Messages


Property changes on: 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoader.php
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/REL1_15/phase3/includes/ResourceLoader.php:51646
/branches/new-installer/phase3/includes/ResourceLoader.php:43664-66004
/branches/resourceloader/phase3/includes/ResourceLoader.php:68366-69676,69678-71999,72001-72255,72257-72305,72307-72342
/branches/sqlite/includes/ResourceLoader.php:58211-58321
/branches/wmf-deployment/includes/ResourceLoader.php:53381
/trunk/phase3/includes/resourceloader/ResourceLoader.php:92580,92713,92765,92884,92886-92887,92894,92898,92907,92932,93149,93151,93233-93234,93258,93266,93516-93518,93818-93822,93847,93858,93891,93935-93936,94068,94155,94235,94346,94372,94422,94425,94444,94448,94456,94498,94601,94728,94825,94862,94995-94997
   + /branches/REL1_15/phase3/includes/ResourceLoader.php:51646
/branches/new-installer/phase3/includes/ResourceLoader.php:43664-66004
/branches/resourceloader/phase3/includes/ResourceLoader.php:68366-69676,69678-71999,72001-72255,72257-72305,72307-72342
/branches/sqlite/includes/ResourceLoader.php:58211-58321
/branches/wmf-deployment/includes/ResourceLoader.php:53381
/trunk/phase3/includes/resourceloader/ResourceLoader.php:92580,92713,92765,92884,92886-92887,92894,92898,92907,92932,93149,93151,93233-93234,93258,93266,93516-93518,93626,93818-93822,93847,93858,93891,93935-93936,94068,94155,94235,94346,94372,94422,94425,94444,94448,94456,94498,94601,94728,94825,94862,94995-94997,96562,96640,96978,97050

Modified: 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderFileModule.php
===================================================================
--- 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderFileModule.php    
    2011-09-16 13:18:40 UTC (rev 97262)
+++ 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderFileModule.php    
    2011-09-16 13:19:04 UTC (rev 97263)
@@ -217,16 +217,21 @@
         */
        public function getScript( ResourceLoaderContext $context ) {
                $files = $this->getScriptFiles( $context );
-               if ( $context->getDebug() && $this->debugRaw ) {
-                       $urls = array();
-                       foreach ( $this->getScriptFiles( $context ) as $file ) {
-                               $urls[] = $this->getRemotePath( $file );
-                       }
-                       return $urls;
-               }
                return $this->readScriptFiles( $files );
        }
+       
+       public function getScriptURLsForDebug( ResourceLoaderContext $context ) 
{
+               $urls = array();
+               foreach ( $this->getScriptFiles( $context ) as $file ) {
+                       $urls[] = $this->getRemotePath( $file );
+               }
+               return $urls;
+       }
 
+       public function supportsURLLoading() {
+               return $this->debugRaw;
+       }
+
        /**
         * Gets loader script.
         *
@@ -250,16 +255,6 @@
                        $this->getStyleFiles( $context ),
                        $this->getFlip( $context )
                );
-               if ( !$context->getOnly() && $context->getDebug() && 
$this->debugRaw ) {
-                       $urls = array();
-                       foreach ( $this->getStyleFiles( $context ) as 
$mediaType => $list ) {
-                               $urls[$mediaType] = array();
-                               foreach ( $list as $file ) {
-                                       $urls[$mediaType][] = 
$this->getRemotePath( $file );
-                               }
-                       }
-                       return $urls;
-               }
                // Collect referenced files
                $this->localFileRefs = array_unique( $this->localFileRefs );
                // If the list has been modified since last time we cached it, 
update the cache
@@ -276,6 +271,17 @@
                return $styles;
        }
 
+       public function getStyleURLsForDebug( ResourceLoaderContext $context ) {
+               $urls = array();
+               foreach ( $this->getStyleFiles( $context ) as $mediaType => 
$list ) {
+                       $urls[$mediaType] = array();
+                       foreach ( $list as $file ) {
+                               $urls[$mediaType][] = $this->getRemotePath( 
$file );
+                       }
+               }
+               return $urls;
+       }
+
        /**
         * Gets list of message keys used by this module.
         *

Modified: 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderModule.php
===================================================================
--- branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderModule.php    
2011-09-16 13:18:40 UTC (rev 97262)
+++ branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderModule.php    
2011-09-16 13:19:04 UTC (rev 97263)
@@ -126,6 +126,44 @@
                // Stub, override expected
                return '';
        }
+       
+       /**
+        * Get the URL or URLs to load for this module's JS in debug mode.
+        * The default behavior is to return a load.php?only=scripts URL for
+        * the module, but file-based modules will want to override this to
+        * load the files directly.
+        * 
+        * This function is called only when 1) we're in debug mode, 2) there
+        * is no only= parameter and 3) supportsURLLoading() returns true.
+        * #2 is important to prevent an infinite loop, therefore this function
+        * MUST return either an only= URL or a non-load.php URL.
+        * 
+        * @param $context ResourceLoaderContext: Context object
+        * @return Array of URLs
+        */
+       public function getScriptURLsForDebug( ResourceLoaderContext $context ) 
{
+               global $wgLoadScript; // TODO factor out to ResourceLoader 
static method and deduplicate from makeResourceLoaderLink()
+               $query = array(
+                       'modules' => $this->getName(),
+                       'only' => 'scripts',
+                       'skin' => $context->getSkin(),
+                       'user' => $context->getUser(),
+                       'debug' => 'true',
+                       'version' => $context->getVersion()
+               );
+               ksort( $query );
+               return array( wfAppendQuery( $wgLoadScript, $query ) . '&*' );
+       }
+       
+       /**
+        * Whether this module supports URL loading. If this function returns 
false,
+        * getScript() will be used even in cases (debug mode, no only param) 
where
+        * getScriptURLsForDebug() would normally be used instead.
+        * @return bool
+        */
+       public function supportsURLLoading() {
+               return true;
+       }
 
        /**
         * Get all CSS for this module for a given skin.
@@ -137,6 +175,29 @@
                // Stub, override expected
                return array();
        }
+       
+       /**
+        * Get the URL or URLs to load for this module's CSS in debug mode.
+        * The default behavior is to return a load.php?only=styles URL for
+        * the module, but file-based modules will want to override this to
+        * load the files directly. See also getScriptURLsForDebug()
+        * 
+        * @param $context ResourceLoaderContext: Context object
+        * @return Array: array( mediaType => array( URL1, URL2, ... ), ... )
+        */
+       public function getStyleURLsForDebug( ResourceLoaderContext $context ) {
+               global $wgLoadScript; // TODO factor out to ResourceLoader 
static method and deduplicate from makeResourceLoaderLink()
+               $query = array(
+                       'modules' => $this->getName(),
+                       'only' => 'styles',
+                       'skin' => $context->getSkin(),
+                       'user' => $context->getUser(),
+                       'debug' => 'true',
+                       'version' => $context->getVersion()
+               );
+               ksort( $query );
+               return array( 'all' => array( wfAppendQuery( $wgLoadScript, 
$query ) . '&*' ) );
+       }
 
        /**
         * Get the messages needed for this module.

Modified: 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
===================================================================
--- 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php 
    2011-09-16 13:18:40 UTC (rev 97262)
+++ 
branches/REL1_18/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php 
    2011-09-16 13:19:04 UTC (rev 97263)
@@ -69,10 +69,6 @@
                        }
                }
 
-
-               $serverBits = wfParseUrl( $wgServer );
-               $protocol = $serverBits ? $serverBits['scheme'] : 'http';
-
                // Build list of variables
                $vars = array(
                        'wgLoadScript' => $wgLoadScript,
@@ -108,7 +104,6 @@
                        'wgFileCanRotate' => BitmapHandler::canRotate(),
                        'wgAvailableSkins' => Skin::getSkinNames(),
                        'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
-                       'wgProto' => $protocol,
                        // MediaWiki sets cookies to have this prefix by default
                        'wgCookiePrefix' => $wgCookiePrefix,
                        'wgResourceLoaderMaxQueryLength' => 
$wgResourceLoaderMaxQueryLength,
@@ -234,6 +229,10 @@
                return $out;
        }
 
+       public function supportsURLLoading() {
+               return false;
+       }
+
        /**
         * @param $context ResourceLoaderContext
         * @return array|mixed


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to