ResourceLoaderWikiModule: Only check content format instead of namespace
authorKunal Mehta <legoktm@gmail.com>
Mon, 15 Sep 2014 05:01:21 +0000 (22:01 -0700)
committerKrinkle <krinklemail@gmail.com>
Tue, 23 Sep 2014 21:30:13 +0000 (21:30 +0000)
Follows up I64e86c741.

Bug: 70835
Change-Id: Ieb9e5d045ed9b59cc83749234a9157689244c597

includes/resourceloader/ResourceLoaderWikiModule.php

index 2eaca67..3b4c3d9 100644 (file)
@@ -81,9 +81,15 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
         * @return null|string
         */
        protected function getContent( $title ) {
-               if ( !$title->isCssJsSubpage() && !$title->isCssOrJsPage() ) {
+               $handler = ContentHandler::getForTitle( $title );
+               if ( $handler->isSupportedFormat( CONTENT_FORMAT_CSS ) ) {
+                       $format = CONTENT_FORMAT_CSS;
+               } elseif ( $handler->isSupportedFormat( CONTENT_FORMAT_JAVASCRIPT ) ) {
+                       $format = CONTENT_FORMAT_JAVASCRIPT;
+               } else {
                        return null;
                }
+
                $revision = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
                if ( !$revision ) {
                        return null;
@@ -96,14 +102,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        return null;
                }
 
-               if ( $content->isSupportedFormat( CONTENT_FORMAT_JAVASCRIPT ) ) {
-                       return $content->serialize( CONTENT_FORMAT_JAVASCRIPT );
-               } elseif ( $content->isSupportedFormat( CONTENT_FORMAT_CSS ) ) {
-                       return $content->serialize( CONTENT_FORMAT_CSS );
-               } else {
-                       wfDebugLog( 'resourceloader', __METHOD__ . ": bad content model {$content->getModel()} for JS/CSS page!" );
-                       return null;
-               }
+               return $content->serialize( $format );
        }
 
        /* Methods */