Merge "(bug 7851) Implement mediawiki.page.patrol.ajax"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderWikiModule.php
index 0f09fc3..1e61a3e 100644 (file)
@@ -68,12 +68,6 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
         * @return null|string
         */
        protected function getContent( $title ) {
-               if ( $title->getNamespace() === NS_MEDIAWIKI ) {
-                       // The first "true" is to use the database, the second is to use the content langue
-                       // and the last one is to specify the message key already contains the language in it ("/de", etc.)
-                       $text = MessageCache::singleton()->get( $title->getDBkey(), true, true, true );
-                       return $text === false ? '' : $text;
-               }
                if ( !$title->isCssJsSubpage() && !$title->isCssOrJsPage() ) {
                        return null;
                }
@@ -81,7 +75,22 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
                if ( !$revision ) {
                        return null;
                }
-               return $revision->getRawText();
+
+               $content = $revision->getContent( Revision::RAW );
+
+               if ( !$content ) {
+                       wfDebug( __METHOD__ . "failed to load content of JS/CSS page!\n" );
+                       return null;
+               }
+
+               $model = $content->getModel();
+
+               if ( $model !== CONTENT_MODEL_CSS && $model !== CONTENT_MODEL_JAVASCRIPT ) {
+                       wfDebug( __METHOD__ . "bad content model $model for JS/CSS page!\n" );
+                       return null;
+               }
+
+               return $content->getNativeData(); //NOTE: this is safe, we know it's JS or CSS
        }
 
        /* Methods */