Merge "Don't modify $wgHooks on language object construction"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 11 Feb 2016 04:05:56 +0000 (04:05 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 11 Feb 2016 04:05:56 +0000 (04:05 +0000)
12 files changed:
includes/page/WikiPage.php
languages/FakeConverter.php
languages/Language.php
languages/LanguageConverter.php
languages/classes/LanguageGan.php
languages/classes/LanguageIu.php
languages/classes/LanguageKk.php
languages/classes/LanguageKu.php
languages/classes/LanguageShi.php
languages/classes/LanguageSr.php
languages/classes/LanguageUz.php
languages/classes/LanguageZh.php

index 598d956..74d4904 100644 (file)
@@ -2211,7 +2211,7 @@ class WikiPage implements Page, IDBAccessObject {
         *   - 'no-change': don't update the article count, ever
         */
        public function doEditUpdates( Revision $revision, User $user, array $options = array() ) {
-               global $wgRCWatchCategoryMembership;
+               global $wgRCWatchCategoryMembership, $wgContLang;
 
                $options += array(
                        'changed' => true,
@@ -2340,6 +2340,10 @@ class WikiPage implements Page, IDBAccessObject {
                        }
 
                        MessageCache::singleton()->replace( $shortTitle, $msgtext );
+
+                       if ( $wgContLang->hasVariants() ) {
+                               $wgContLang->updateConversionTable( $this->mTitle );
+                       }
                }
 
                if ( $options['created'] ) {
@@ -3287,6 +3291,8 @@ class WikiPage implements Page, IDBAccessObject {
         * @param Title $title
         */
        public static function onArticleDelete( Title $title ) {
+               global $wgContLang;
+
                // Update existence markers on article/talk tabs...
                $other = $title->getOtherPage();
 
@@ -3302,6 +3308,10 @@ class WikiPage implements Page, IDBAccessObject {
                // Messages
                if ( $title->getNamespace() == NS_MEDIAWIKI ) {
                        MessageCache::singleton()->replace( $title->getDBkey(), false );
+
+                       if ( $wgContLang->hasVariants() ) {
+                               $wgContLang->updateConversionTable( $title );
+                       }
                }
 
                // Images
index 1b6e9d6..b953405 100644 (file)
@@ -114,4 +114,7 @@ class FakeConverter {
        function translate( $text, $variant ) {
                return $text;
        }
+
+       public function updateConversionTable( Title $title ) {
+       }
 }
index 42c5a57..c094215 100644 (file)
@@ -4231,6 +4231,16 @@ class Language {
                return $this->mConverter->getParsedTitle();
        }
 
+       /**
+        * Refresh the cache of conversion tables when
+        * MediaWiki:Conversiontable* is updated.
+        *
+        * @param Title $titleobj The Title of the page being updated
+        */
+       public function updateConversionTable( Title $title ) {
+               $this->mConverter->updateConversionTable( $title );
+       }
+
        /**
         * Prepare external link text for conversion. When the text is
         * a URL, it shouldn't be converted, and it'll be wrapped in
index b00aa34..4eeba64 100644 (file)
@@ -1053,24 +1053,12 @@ class LanguageConverter {
        }
 
        /**
-        * Hook to refresh the cache of conversion tables when
+        * Refresh the cache of conversion tables when
         * MediaWiki:Conversiontable* is updated.
-        * @private
         *
-        * @param WikiPage $page
-        * @param User $user User object for the current user
-        * @param Content $content New page content
-        * @param string $summary Edit summary of the edit
-        * @param bool $isMinor Was the edit marked as minor?
-        * @param null $isWatch Unused.
-        * @param null $section Unused.
-        * @param int $flags Bitfield
-        * @param Revision|null $revision New Revision object or null
-        * @return bool True
+        * @param Title $titleobj The Title of the page being updated
         */
-       function OnPageContentSaveComplete( $page, $user, $content, $summary, $isMinor,
-                       $isWatch, $section, $flags, $revision ) {
-               $titleobj = $page->getTitle();
+       public function updateConversionTable( Title $titleobj ) {
                if ( $titleobj->getNamespace() == NS_MEDIAWIKI ) {
                        $title = $titleobj->getDBkey();
                        $t = explode( '/', $title, 3 );
@@ -1081,7 +1069,6 @@ class LanguageConverter {
                                }
                        }
                }
-               return true;
        }
 
        /**
index 9dc3a86..7582f56 100644 (file)
@@ -78,7 +78,6 @@ class GanConverter extends LanguageConverter {
  */
 class LanguageGan extends LanguageZh {
        function __construct() {
-               global $wgHooks;
                parent::__construct();
 
                $variants = array( 'gan', 'gan-hans', 'gan-hant' );
@@ -95,8 +94,6 @@ class LanguageGan extends LanguageZh {
                        $variants, $variantfallbacks,
                        array(),
                        $ml );
-
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 
        /**
index af0431f..93cc2c8 100644 (file)
@@ -190,8 +190,6 @@ class IuConverter extends LanguageConverter {
  */
 class LanguageIu extends Language {
        function __construct() {
-               global $wgHooks;
-
                parent::__construct();
 
                $variants = array( 'iu', 'ike-cans', 'ike-latn' );
@@ -203,6 +201,5 @@ class LanguageIu extends Language {
 
                $flags = array();
                $this->mConverter = new IuConverter( $this, 'iu', $variants, $variantfallbacks, $flags );
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 }
index 0357730..bac493b 100644 (file)
@@ -392,7 +392,6 @@ class KkConverter extends LanguageConverter {
  */
 class LanguageKk extends LanguageKk_cyrl {
        function __construct() {
-               global $wgHooks;
                parent::__construct();
 
                $variants = array( 'kk', 'kk-cyrl', 'kk-latn', 'kk-arab', 'kk-kz', 'kk-tr', 'kk-cn' );
@@ -407,8 +406,6 @@ class LanguageKk extends LanguageKk_cyrl {
                );
 
                $this->mConverter = new KkConverter( $this, 'kk', $variants, $variantfallbacks );
-
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 
        /**
index c14f468..ee54b8b 100644 (file)
@@ -230,7 +230,6 @@ class KuConverter extends LanguageConverter {
 class LanguageKu extends LanguageKu_ku {
 
        function __construct() {
-               global $wgHooks;
                parent::__construct();
 
                $variants = array( 'ku', 'ku-arab', 'ku-latn' );
@@ -241,6 +240,5 @@ class LanguageKu extends LanguageKu_ku {
                );
 
                $this->mConverter = new KuConverter( $this, 'ku', $variants, $variantfallbacks );
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 }
index afd7283..2787ca3 100644 (file)
@@ -166,8 +166,6 @@ class ShiConverter extends LanguageConverter {
  */
 class LanguageShi extends Language {
        function __construct() {
-               global $wgHooks;
-
                parent::__construct();
 
                $variants = array( 'shi', 'shi-tfng', 'shi-latn' );
@@ -179,6 +177,5 @@ class LanguageShi extends Language {
 
                $flags = array();
                $this->mConverter = new ShiConverter( $this, 'shi', $variants, $variantfallbacks, $flags );
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 }
index ece50e8..1ffb321 100644 (file)
@@ -198,8 +198,6 @@ class SrConverter extends LanguageConverter {
  */
 class LanguageSr extends Language {
        function __construct() {
-               global $wgHooks;
-
                parent::__construct();
 
                $variants = array( 'sr', 'sr-ec', 'sr-el' );
@@ -214,6 +212,5 @@ class LanguageSr extends Language {
                        'W' => 'W', 'реч' => 'W', 'reč' => 'W', 'ријеч' => 'W', 'riječ' => 'W'
                );
                $this->mConverter = new SrConverter( $this, 'sr', $variants, $variantfallbacks, $flags );
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 }
index 6910d9c..d37a207 100644 (file)
@@ -132,7 +132,6 @@ class UzConverter extends LanguageConverter {
  */
 class LanguageUz extends Language {
        function __construct() {
-               global $wgHooks;
                parent::__construct();
 
                $variants = array( 'uz', 'uz-latn', 'uz-cyrl' );
@@ -143,6 +142,5 @@ class LanguageUz extends Language {
                );
 
                $this->mConverter = new UzConverter( $this, 'uz', $variants, $variantfallbacks );
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 }
index 51b09f6..36345c9 100644 (file)
@@ -111,8 +111,6 @@ class ZhConverter extends LanguageConverter {
  */
 class LanguageZh extends LanguageZh_hans {
        function __construct() {
-               global $wgHooks;
-
                parent::__construct();
 
                $variants = array(
@@ -148,8 +146,6 @@ class LanguageZh extends LanguageZh_hans {
                                                                $variants, $variantfallbacks,
                                                                array(),
                                                                $ml );
-
-               $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
 
        /**