Merge "jquery.accessKeyLabel: Update Opera access keys"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index 5208c23..414f8e2 100644 (file)
@@ -197,7 +197,7 @@ class ResourceLoader implements LoggerAwareInterface {
                }
 
                $stats = RequestContext::getMain()->getStats();
-               $cache = ObjectCache::newAccelerator( CACHE_ANYTHING );
+               $cache = ObjectCache::getLocalServerInstance( CACHE_ANYTHING );
 
                $key = $cache->makeGlobalKey(
                        'resourceloader',
@@ -274,7 +274,7 @@ class ResourceLoader implements LoggerAwareInterface {
                        $this->registerTestModules();
                }
 
-               $this->setMessageBlobStore( new MessageBlobStore() );
+               $this->setMessageBlobStore( new MessageBlobStore( $this ) );
        }
 
        /**
@@ -435,6 +435,8 @@ class ResourceLoader implements LoggerAwareInterface {
        /**
         * Add a foreign source of modules.
         *
+        * Source IDs are typically the same as the Wiki ID or database name (e.g. lowercase a-z).
+        *
         * @param array|string $id Source ID (string), or array( id1 => loadUrl, id2 => loadUrl, ... )
         * @param string|array $loadUrl load.php url (string), or array with loadUrl key for
         *  backwards-compatibility.
@@ -708,8 +710,11 @@ class ResourceLoader implements LoggerAwareInterface {
 
                // Capture any PHP warnings from the output buffer and append them to the
                // error list if we're in debug mode.
-               if ( $context->getDebug() && strlen( $warnings = ob_get_contents() ) ) {
-                       $this->errors[] = $warnings;
+               if ( $context->getDebug() ) {
+                       $warnings = ob_get_contents();
+                       if ( strlen( $warnings ) ) {
+                               $this->errors[] = $warnings;
+                       }
                }
 
                // Save response to file cache unless there are errors
@@ -799,11 +804,6 @@ class ResourceLoader implements LoggerAwareInterface {
                        $exp = min( $maxage, $smaxage );
                        header( 'Expires: ' . wfTimestamp( TS_RFC2822, $exp + time() ) );
                }
-
-               // Send the current time expressed as fractional seconds since epoch,
-               // with microsecond precision. This helps distinguish hits from misses
-               // in edge caches.
-               header( 'MediaWiki-Timestamp: ' . microtime( true ) );
        }
 
        /**
@@ -877,8 +877,11 @@ class ResourceLoader implements LoggerAwareInterface {
                        $response = $fileCache->fetchText();
                        // Capture any PHP warnings from the output buffer and append them to the
                        // response in a comment if we're in debug mode.
-                       if ( $context->getDebug() && strlen( $warnings = ob_get_contents() ) ) {
-                               $response = self::makeComment( $warnings ) . $response;
+                       if ( $context->getDebug() ) {
+                               $warnings = ob_get_contents();
+                               if ( strlen( $warnings ) ) {
+                                       $response = self::makeComment( $warnings ) . $response;
+                               }
                        }
                        // Remove the output buffer and output the response
                        ob_end_clean();
@@ -1068,6 +1071,23 @@ MESSAGE;
                return $out;
        }
 
+       /**
+        * Get names of modules that use a certain message.
+        *
+        * @param string $messageKey
+        * @return array List of module names
+        */
+       public function getModulesByMessage( $messageKey ) {
+               $moduleNames = array();
+               foreach ( $this->getModuleNames() as $moduleName ) {
+                       $module = $this->getModule( $moduleName );
+                       if ( in_array( $messageKey, $module->getMessages() ) ) {
+                               $moduleNames[] = $moduleName;
+                       }
+               }
+               return $moduleNames;
+       }
+
        /* Static Methods */
 
        /**