http://www.mediawiki.org/wiki/Special:Code/MediaWiki/84626

Revision: 84626
Author:   ialex
Date:     2011-03-23 19:26:37 +0000 (Wed, 23 Mar 2011)
Log Message:
-----------
Use a static variable to save whether is a redirect instead of storing it in 
$wgParser

Modified Paths:
--------------
    trunk/extensions/DidYouMean/DidYouMean.hooks.php

Modified: trunk/extensions/DidYouMean/DidYouMean.hooks.php
===================================================================
--- trunk/extensions/DidYouMean/DidYouMean.hooks.php    2011-03-23 19:18:22 UTC 
(rev 84625)
+++ trunk/extensions/DidYouMean/DidYouMean.hooks.php    2011-03-23 19:26:37 UTC 
(rev 84626)
@@ -3,6 +3,7 @@
  * All the hooks for DidYouMean
  */
 class DidYouMeanHooks {
+       private static $articleIsRedirect = false;
 
        # TODO this is called even when editing a new page
        public static function articleNoArticleText( &$article, &$text ) {
@@ -142,34 +143,34 @@
        
        # called at action=edit. can detect if we're about to edit a redirect
        public static function alternateEdit( $editpage ) {
-               global $wgParser;
-   
-               if ($editpage->mArticle->isRedirect())
-                       $wgParser->mDymRedirBeforeEdit = true;
-   
-               return 1;
+               if ( $editpage->mArticle->isRedirect() ) {
+                       self::$articleIsRedirect = true;
+               }
+
+               return true;
        }
-       
+
        # called at end of action=submit
        public static function articleSaveComplete( $article, $user, $text, 
$summary, $isminor, $dunno1, $dunno2, $flags ) {
-               global $wgParser;
-   
-               if ($article->getTitle()->getNamespace() != 0)
+               if ( $article->getTitle()->getNamespace() != 0 ) {
                        return true;
-   
-               if ($article->isRedirect($text)) {
-                       if (empty( $wgParser->mDymRedirBeforeEdit ) && !($flags 
& EDIT_NEW))
+               }
+
+               if ( $article->isRedirect( $text ) ) {
+                       if ( !self::$articleIsRedirect && !( $flags & EDIT_NEW 
) ) {
                                DidYouMean::doDelete( $article->getID() );
+                       }
                } else {
-                       if (!empty( $wgParser->mDymRedirBeforeEdit ) || $flags 
& EDIT_NEW)
+                       if ( self::$articleIsRedirect || $flags & EDIT_NEW ) {
                                DidYouMean::doInsert( $article->getID(), 
$article->getTitle()->getText() );
+                       }
                }
-   
-               $wgParser->mDymRedirBeforeEdit = false;
-   
+
+               self::$articleIsRedirect = false;
+
                return true;
        }
-       
+
        public static function articleUndelete( &$title, &$create ) {
    
                if ($create == false || $title->getNamespace() != 0)


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to