* @param $lang string Language code
* @return array An array mapping module names to message blobs
*/
- public static function get( $modules, $lang ) {
+ public static function get( ResourceLoader $resourceLoader, $modules, $lang ) {
// TODO: Invalidate blob when module touched
wfProfileIn( __METHOD__ );
if ( !count( $modules ) ) {
return array();
}
// Try getting from the DB first
- $blobs = self::getFromDB( array_keys( $modules ), $lang );
+ $blobs = self::getFromDB( $resourceLoader, array_keys( $modules ), $lang );
// Generate blobs for any missing modules and store them in the DB
$missing = array_diff( array_keys( $modules ), array_keys( $blobs ) );
* @param $lang string Language code
* @return array Array mapping module names to blobs
*/
- private static function getFromDB( $modules, $lang ) {
+ private static function getFromDB( ResourceLoader $resourceLoader, $modules, $lang ) {
$retval = array();
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'msg_resource',
);
foreach ( $res as $row ) {
- $module = ResourceLoader::getModule( $row->mr_resource );
+ $module = $resourceLoader->getModule( $row->mr_resource );
if ( !$module ) {
// This shouldn't be possible
throw new MWException( __METHOD__ . ' passed an invalid module name' );
public function makeModuleResponse( ResourceLoaderContext $context, array $modules, $missing = null ) {
// Pre-fetch blobs
$blobs = $context->shouldIncludeMessages() ?
- MessageBlobStore::get( $modules, $context->getLanguage() ) : array();
+ MessageBlobStore::get( $this, $modules, $context->getLanguage() ) : array();
// Generate output
$out = '';