if ( $module instanceof ResourceLoaderModule
&& $module->getOrigin() <= $this->getAllowedModules( $type )
&& ( is_null( $position ) || $module->getPosition() == $position )
- && ( !$this->mTarget || in_array( $this->mTarget, $module->getTargets() ) )
) {
+ if ( $this->mTarget && !in_array( $this->mTarget, $module->getTargets() ) ) {
+ $this->warnModuleTargetFilter( $module->getName() );
+ continue;
+ }
$filteredModules[] = $val;
}
}
return $filteredModules;
}
+ private function warnModuleTargetFilter( $moduleName ) {
+ static $warnings = [];
+ if ( isset( $warnings[$this->mTarget][$moduleName] ) ) {
+ return;
+ }
+ $warnings[$this->mTarget][$moduleName] = true;
+ $this->getResourceLoader()->getLogger()->debug(
+ 'Module "{module}" not loadable on target "{target}".',
+ [
+ 'module' => $moduleName,
+ 'target' => $this->mTarget,
+ ]
+ );
+ }
+
/**
* Get the list of modules to include on this page
*
$query['returntoquery'] = wfArrayToCgi( $returntoquery );
}
}
- $loginLink = Linker::linkKnown(
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ $loginLink = $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor( 'Userlogin' ),
- $this->msg( 'loginreqlink' )->escaped(),
+ $this->msg( 'loginreqlink' )->text(),
[],
$query
);
}
foreach ( $this->mMetatags as $tag ) {
- if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
+ if ( strncasecmp( $tag[0], 'http:', 5 ) === 0 ) {
$a = 'http-equiv';
$tag[0] = substr( $tag[0], 5 );
+ } elseif ( strncasecmp( $tag[0], 'og:', 3 ) === 0 ) {
+ $a = 'property';
} else {
$a = 'name';
}
*/
public static function transformResourcePath( Config $config, $path ) {
global $IP;
+
+ $localDir = $IP;
$remotePathPrefix = $config->get( 'ResourceBasePath' );
if ( $remotePathPrefix === '' ) {
// The configured base path is required to be empty string for
// - Path is protocol-relative. Fixes T155310. Not supported by RelPath lib.
return $path;
}
+ // For files in resources, extensions/ or skins/, ResourceBasePath is preferred here.
+ // For other misc files in $IP, we'll fallback to that as well. There is, however, a fourth
+ // supported dir/path pair in the configuration (wgUploadDirectory, wgUploadPath)
+ // which is not expected to be in wgResourceBasePath on CDNs. (T155146)
+ $uploadPath = $config->get( 'UploadPath' );
+ if ( strpos( $path, $uploadPath ) === 0 ) {
+ $localDir = $config->get( 'UploadDirectory' );
+ $remotePathPrefix = $remotePath = $uploadPath;
+ }
+
$path = RelPath\getRelativePath( $path, $remotePath );
- return self::transformFilePath( $remotePathPrefix, $IP, $path );
+ return self::transformFilePath( $remotePathPrefix, $localDir, $path );
}
/**