(Bug 41493) Move PageContentLanguage hook to Content class
authordaniel <daniel.kinzler@wikimedia.de>
Mon, 29 Oct 2012 17:08:04 +0000 (18:08 +0100)
committerdaniel <daniel.kinzler@wikimedia.de>
Mon, 29 Oct 2012 17:08:04 +0000 (18:08 +0100)
This change moves the PageContentLanguage hook from Title::getPageLanguage
to Content::getPageLanguage, so the hook is no longer bypassed by
Content::getPageViewLanguage and consequently Title::getPageViewLanguage.

Change-Id: I51dabe9aee9d544483e7416a8fdf7721638d21bf

includes/Title.php
includes/content/ContentHandler.php

index 00fdc3a..9ec6ec9 100644 (file)
@@ -4701,8 +4701,6 @@ class Title {
                $contentHandler = ContentHandler::getForTitle( $this );
                $pageLang = $contentHandler->getPageLanguage( $this );
 
-               // Hook at the end because we don't want to override the above stuff
-               wfRunHooks( 'PageContentLanguage', array( $this, &$pageLang, $wgLang ) );
                return wfGetLangObj( $pageLang );
        }
 
index 8e8de4b..ee2f2ed 100644 (file)
@@ -607,15 +607,17 @@ abstract class ContentHandler {
         * @return Language the page's language
         */
        public function getPageLanguage( Title $title, Content $content = null ) {
-               global $wgContLang;
+               global $wgContLang, $wgLang;
+               $pageLang = $wgContLang;
 
                if ( $title->getNamespace() == NS_MEDIAWIKI ) {
                        // Parse mediawiki messages with correct target language
                        list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() );
-                       return wfGetLangObj( $lang );
+                       $pageLang = wfGetLangObj( $lang );
                }
 
-               return $wgContLang;
+               wfRunHooks( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) );
+               return wfGetLangObj( $pageLang );
        }
 
        /**