API: Add "messagecode" to AuthManager responses
[lhc/web/wiklou.git] / includes / OutputPage.php
index 211f44b..eb2f7e7 100644 (file)
@@ -534,14 +534,32 @@ class OutputPage extends ContextSource {
                        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
         *
@@ -2515,9 +2533,10 @@ class OutputPage extends ContextSource {
                                        $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
                        );
@@ -3258,9 +3277,11 @@ class OutputPage extends ContextSource {
                }
 
                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';
                        }
@@ -3562,7 +3583,6 @@ class OutputPage extends ContextSource {
        protected function buildExemptModules() {
                global $wgContLang;
 
-               $resourceLoader = $this->getResourceLoader();
                $chunks = [];
                // Things that go after the ResourceLoaderDynamicStyles marker
                $append = [];
@@ -3695,6 +3715,8 @@ class OutputPage extends ContextSource {
         */
        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
@@ -3703,12 +3725,23 @@ class OutputPage extends ContextSource {
                } else {
                        $remotePath = $remotePathPrefix;
                }
-               if ( strpos( $path, $remotePath ) !== 0 ) {
-                       // Path is outside wgResourceBasePath, ignore.
+               if ( strpos( $path, $remotePath ) !== 0 || substr( $path, 0, 2 ) === '//' ) {
+                       // - Path is outside wgResourceBasePath, ignore.
+                       // - 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 );
        }
 
        /**