X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FMessageBlobStore.php;h=5725898420eb75bf1f634f90388b676589bafaf0;hb=d506171b58c9aa98d5c50274a01b2df369c1a185;hp=f5b346c4534eda595bcc7ef9949eb857328d552e;hpb=75e46771dc4a848ef116001a74c3c1a54c3af695;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MessageBlobStore.php b/includes/MessageBlobStore.php index f5b346c453..5725898420 100644 --- a/includes/MessageBlobStore.php +++ b/includes/MessageBlobStore.php @@ -32,7 +32,6 @@ * constituent messages or the resource itself is changed. */ class MessageBlobStore { - /** * Get the message blobs for a set of modules * @@ -128,7 +127,8 @@ class MessageBlobStore { * @param string $name Module name * @param ResourceLoaderModule $module * @param string $lang Language code - * @return string Regenerated message blob, or null if there was no blob for the given module/language pair + * @return string Regenerated message blob, or null if there was no blob for + * the given module/language pair. */ public static function updateModule( $name, ResourceLoaderModule $module, $lang ) { $dbw = wfGetDB( DB_MASTER ); @@ -331,6 +331,7 @@ class MessageBlobStore { */ private static function getFromDB( ResourceLoader $resourceLoader, $modules, $lang ) { global $wgCacheEpoch; + $retval = array(); $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'msg_resource', @@ -345,10 +346,14 @@ class MessageBlobStore { // This shouldn't be possible throw new MWException( __METHOD__ . ' passed an invalid module name' ); } + // Update the module's blobs if the set of messages changed or if the blob is // older than $wgCacheEpoch - if ( array_keys( FormatJson::decode( $row->mr_blob, true ) ) !== array_values( array_unique( $module->getMessages() ) ) || - wfTimestamp( TS_MW, $row->mr_timestamp ) <= $wgCacheEpoch ) { + $keys = array_keys( FormatJson::decode( $row->mr_blob, true ) ); + $values = array_values( array_unique( $module->getMessages() ) ); + if ( $keys !== $values + || wfTimestamp( TS_MW, $row->mr_timestamp ) <= $wgCacheEpoch + ) { $retval[$row->mr_resource] = self::updateModule( $row->mr_resource, $module, $lang ); } else { $retval[$row->mr_resource] = $row->mr_blob;