'wgSearchType' => $conf->get( 'SearchType' ),
'wgVariantArticlePath' => $conf->get( 'VariantArticlePath' ),
// Force object to avoid "empty" associative array from
- // becoming [] instead of {} in JS (bug 34604)
+ // becoming [] instead of {} in JS (T36604)
'wgActionPaths' => (object)$conf->get( 'ActionPaths' ),
'wgServer' => $conf->get( 'Server' ),
'wgServerName' => $conf->get( 'ServerName' ),
* @return string JavaScript code for registering all modules with the client loader
*/
public function getModuleRegistrations( ResourceLoaderContext $context ) {
-
$resourceLoader = $context->getResourceLoader();
$target = $context->getRequest()->getVal( 'target', 'desktop' );
// Bypass target filter if this request is Special:JavaScriptTest.
$byPassTargetFilter = $this->getConfig()->get( 'EnableJavaScriptTest' ) && $target === 'test';
$out = '';
+ $states = [];
$registryData = [];
// Get registry data
continue;
}
- $versionHash = $module->getVersionHash( $context );
- if ( strlen( $versionHash ) !== 7 ) {
+ try {
+ $versionHash = $module->getVersionHash( $context );
+ } catch ( Exception $e ) {
+ // See also T152266 and ResourceLoader::getCombinedVersion()
+ MWExceptionHandler::logException( $e );
+ $context->getLogger()->warning(
+ 'Calculating version for "{module}" failed: {exception}',
+ [
+ 'module' => $name,
+ 'exception' => $e,
+ ]
+ );
+ $versionHash = '';
+ $states[$name] = 'error';
+ }
+
+ if ( $versionHash !== '' && strlen( $versionHash ) !== 7 ) {
$context->getLogger()->warning(
"Module '{module}' produced an invalid version hash: '{version}'.",
[
// Register modules
$out .= "\n" . ResourceLoader::makeLoaderRegisterScript( $registrations );
+ if ( $states ) {
+ $out .= "\n" . ResourceLoader::makeLoaderStateScript( $states );
+ }
+
return $out;
}