Move LanguageGetMagic hook to its own function
authorPlatonides <platonides@users.mediawiki.org>
Thu, 10 Feb 2011 18:15:58 +0000 (18:15 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Thu, 10 Feb 2011 18:15:58 +0000 (18:15 +0000)
languages/Language.php

index 9631ce2..07e3619 100644 (file)
@@ -2095,14 +2095,20 @@ class Language {
                return self::$dataCache->getItem( $this->mCode, 'magicWords' );
        }
 
+       protected function doMagicHook() {
+               if ( $this->mMagicHookDone ) {
+                       return;
+               }
+               $this->mMagicHookDone = true;
+               wfProfileIn( 'LanguageGetMagic' );
+               wfRunHooks( 'LanguageGetMagic', array( &$this->mMagicExtensions, $this->getCode() ) );
+               wfProfileOut( 'LanguageGetMagic' );
+       }
+
        # Fill a MagicWord object with data from here
        function getMagic( $mw ) {
-               if ( !$this->mMagicHookDone ) {
-                       $this->mMagicHookDone = true;
-                       wfProfileIn( 'LanguageGetMagic' );
-                       wfRunHooks( 'LanguageGetMagic', array( &$this->mMagicExtensions, $this->getCode() ) );
-                       wfProfileOut( 'LanguageGetMagic' );
-               }
+               $this->doMagicHook();
+
                if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
                        $rawEntry = $this->mMagicExtensions[$mw->mId];
                } else {