X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderWikiModule.php;h=f6f14b37d48795a3244205da628a65c2cd47899a;hb=cac0d75f3624529222b9dcd1a1283b9f2b93eceb;hp=14d6e056e0642ae69dd65b8c9f086f0d09fe63aa;hpb=9aba586d3b758719d9aa08b236a9de93956b6a96;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index 14d6e056e0..f6f14b37d4 100644 --- a/includes/resourceloader/ResourceLoaderWikiModule.php +++ b/includes/resourceloader/ResourceLoaderWikiModule.php @@ -149,6 +149,15 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { return null; } + // If the page is a redirect, follow the redirect. + if ( $title->isRedirect() ) { + $content = $this->getContentObj( $title ); + $title = $content ? $content->getUltimateRedirectTarget() : null; + if ( !$title ) { + return null; + } + } + $handler = ContentHandler::getForTitle( $title ); if ( $handler->isSupportedFormat( CONTENT_FORMAT_CSS ) ) { $format = CONTENT_FORMAT_CSS; @@ -158,6 +167,19 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { return null; } + $content = $this->getContentObj( $title ); + if ( !$content ) { + return null; + } + + return $content->serialize( $format ); + } + + /** + * @param Title $title + * @return Content|null + */ + protected function getContentObj( Title $title ) { $revision = Revision::newKnownCurrent( wfGetDB( DB_REPLICA ), $title->getArticleID(), $title->getLatestRevID() ); if ( !$revision ) { @@ -165,13 +187,11 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { } $revision->setTitle( $title ); $content = $revision->getContent( Revision::RAW ); - if ( !$content ) { wfDebugLog( 'resourceloader', __METHOD__ . ': failed to load content of JS/CSS page!' ); return null; } - - return $content->serialize( $format ); + return $content; } /** @@ -268,7 +288,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { return true; } - // Bug 68488: For other modules (i.e. ones that are called in cached html output) only check + // T70488: For other modules (i.e. ones that are called in cached html output) only check // page existance. This ensures that, if some pages in a module are temporarily blanked, // we don't end omit the module's script or link tag on some pages. return count( $revisions ) === 0; @@ -357,6 +377,11 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { } } + if ( !$wikiModules ) { + // Nothing to preload + return; + } + $pageNames = array_keys( $allPages ); sort( $pageNames ); $hash = sha1( implode( '|', $pageNames ) );