Merge "Allow patrolling page creations from Special:RecentChanges"
[lhc/web/wiklou.git] / languages / Language.php
index ea34363..92ea75c 100644 (file)
@@ -2953,12 +2953,16 @@ class Language {
        }
 
        /**
+        * Get all magic words from cache.
         * @return array
         */
        function getMagicWords() {
                return self::$dataCache->getItem( $this->mCode, 'magicWords' );
        }
 
+       /**
+        * Run the LanguageGetMagic hook once.
+        */
        protected function doMagicHook() {
                if ( $this->mMagicHookDone ) {
                        return;
@@ -2975,17 +2979,16 @@ class Language {
         * @param $mw
         */
        function getMagic( $mw ) {
-               $this->doMagicHook();
+               // Saves a function call
+               if ( ! $this->mMagicHookDone ) {
+                       $this->doMagicHook();
+               }
 
                if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
                        $rawEntry = $this->mMagicExtensions[$mw->mId];
                } else {
-                       $magicWords = $this->getMagicWords();
-                       if ( isset( $magicWords[$mw->mId] ) ) {
-                               $rawEntry = $magicWords[$mw->mId];
-                       } else {
-                               $rawEntry = false;
-                       }
+                       $rawEntry = self::$dataCache->getSubitem(
+                               $this->mCode, 'magicWords', $mw->mId );
                }
 
                if ( !is_array( $rawEntry ) ) {