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
*
*/
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 );
}
/**