* Follow-up r84610: don't assume a Parser object is attached
[lhc/web/wiklou.git] / includes / OutputPage.php
index 576be09..a9e549a 100644 (file)
@@ -123,6 +123,7 @@ class OutputPage {
        var $mInlineMsg = array();
 
        var $mTemplateIds = array();
+       var $mImageTimeKeys = array();
 
        # What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page?
        # @see ResourceLoaderModule::$origin
@@ -361,7 +362,8 @@ class OutputPage {
        }
 
        /**
-        * Filter an array of modules to remove insufficiently trustworthy members
+        * Filter an array of modules to remove insufficiently trustworthy members, and modules
+        * which are no longer registered (eg a page is cached before an extension is disabled)
         * @param $modules Array
         * @return Array
         */
@@ -370,7 +372,9 @@ class OutputPage {
                $filteredModules = array();
                foreach( $modules as $val ){
                        $module = $resourceLoader->getModule( $val );
-                       if( $module->getOrigin() <= $this->getAllowedModules( $type ) ) {
+                       if( $module instanceof ResourceLoaderModule
+                               && $module->getOrigin() <= $this->getAllowedModules( $type ) )
+                       {
                                $filteredModules[] = $val;
                        }
                }
@@ -1305,14 +1309,19 @@ class OutputPage {
                $this->mNoGallery = $parserOutput->getNoGallery();
                $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
                $this->addModules( $parserOutput->getModules() );
-               // Versioning...
-               foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) {
+
+               // Template versioning...
+               foreach ( (array)$parserOutput->getTemplateIds() as $ns => $dbks ) {
                        if ( isset( $this->mTemplateIds[$ns] ) ) {
                                $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
                        } else {
                                $this->mTemplateIds[$ns] = $dbks;
                        }
                }
+               // File versioning...
+               foreach ( (array)$parserOutput->getImageTimeKeys() as $dbk => $data ) {
+                       $this->mImageTimeKeys[$dbk] = $data;
+               }
 
                // Hooks registered in the object
                global $wgParserOutputHooks;
@@ -1895,7 +1904,7 @@ class OutputPage {
                $this->setRobotPolicy( 'noindex,nofollow' );
                $this->setArticleRelated( false );
 
-               $name = User::whoIs( $wgUser->blockedBy() );
+               $name = $wgUser->blockedBy();
                $reason = $wgUser->blockedFor();
                if( $reason == '' ) {
                        $reason = wfMsg( 'blockednoreason' );
@@ -1907,29 +1916,9 @@ class OutputPage {
 
                $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
 
-               $blockid = $wgUser->mBlock->mId;
+               $blockid = $wgUser->mBlock->getId();
 
-               $blockExpiry = $wgUser->mBlock->mExpiry;
-               if ( $blockExpiry == 'infinity' ) {
-                       // Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite'
-                       // Search for localization in 'ipboptions'
-                       $scBlockExpiryOptions = wfMsg( 'ipboptions' );
-                       foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
-                               if ( strpos( $option, ':' ) === false ) {
-                                       continue;
-                               }
-                               list( $show, $value ) = explode( ':', $option );
-                               if ( $value == 'infinite' || $value == 'indefinite' ) {
-                                       $blockExpiry = $show;
-                                       break;
-                               }
-                       }
-               } else {
-                       $blockExpiry = $wgLang->timeanddate(
-                               wfTimestamp( TS_MW, $blockExpiry ),
-                               true
-                       );
-               }
+               $blockExpiry = $wgLang->formatExpiry( $wgUser->mBlock->mExpiry );
 
                if ( $wgUser->mBlock->mAuto ) {
                        $msg = 'autoblockedtext';
@@ -1939,7 +1928,7 @@ class OutputPage {
 
                /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
                 * This could be a username, an IP range, or a single IP. */
-               $intended = $wgUser->mBlock->mAddress;
+               $intended = $wgUser->mBlock->getTarget();
 
                $this->addWikiMsg(
                        $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry,
@@ -2505,10 +2494,12 @@ class OutputPage {
                                }
                                continue;
                        }
-                       // Special handling for user and site groups; because users might change their stuff
-                       // on-wiki like site or user pages, or user preferences; we need to find the highest
+                       // Special handling for the user group; because users might change their stuff
+                       // on-wiki like user pages, or user preferences; we need to find the highest
                        // timestamp of these user-changable modules so we can ensure cache misses on change
-                       if ( $group === 'user' || $group === 'site' ) {
+                       // This should NOT be done for the site group (bug 27564) because anons get that too
+                       // and we shouldn't be putting timestamps in Squid-cached HTML
+                       if ( $group === 'user' ) {
                                // Get the maximum timestamp
                                $timestamp = 1;
                                foreach ( $modules as $module ) {