r84626 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84625‎ | r84626 | r84627 >
Date:19:26, 23 March 2011
Author:ialex
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/DidYouMean/DidYouMean.hooks.php
@@ -3,6 +3,7 @@
44 * All the hooks for DidYouMean
55 */
66 class DidYouMeanHooks {
 7+ private static $articleIsRedirect = false;
78
89 # TODO this is called even when editing a new page
910 public static function articleNoArticleText( &$article, &$text ) {
@@ -142,34 +143,34 @@
143144
144145 # called at action=edit. can detect if we're about to edit a redirect
145146 public static function alternateEdit( $editpage ) {
146 - global $wgParser;
147 -
148 - if ($editpage->mArticle->isRedirect())
149 - $wgParser->mDymRedirBeforeEdit = true;
150 -
151 - return 1;
 147+ if ( $editpage->mArticle->isRedirect() ) {
 148+ self::$articleIsRedirect = true;
 149+ }
 150+
 151+ return true;
152152 }
153 -
 153+
154154 # called at end of action=submit
155155 public static function articleSaveComplete( $article, $user, $text, $summary, $isminor, $dunno1, $dunno2, $flags ) {
156 - global $wgParser;
157 -
158 - if ($article->getTitle()->getNamespace() != 0)
 156+ if ( $article->getTitle()->getNamespace() != 0 ) {
159157 return true;
160 -
161 - if ($article->isRedirect($text)) {
162 - if (empty( $wgParser->mDymRedirBeforeEdit ) && !($flags & EDIT_NEW))
 158+ }
 159+
 160+ if ( $article->isRedirect( $text ) ) {
 161+ if ( !self::$articleIsRedirect && !( $flags & EDIT_NEW ) ) {
163162 DidYouMean::doDelete( $article->getID() );
 163+ }
164164 } else {
165 - if (!empty( $wgParser->mDymRedirBeforeEdit ) || $flags & EDIT_NEW)
 165+ if ( self::$articleIsRedirect || $flags & EDIT_NEW ) {
166166 DidYouMean::doInsert( $article->getID(), $article->getTitle()->getText() );
 167+ }
167168 }
168 -
169 - $wgParser->mDymRedirBeforeEdit = false;
170 -
 169+
 170+ self::$articleIsRedirect = false;
 171+
171172 return true;
172173 }
173 -
 174+
174175 public static function articleUndelete( &$title, &$create ) {
175176
176177 if ($create == false || $title->getNamespace() != 0)

Status & tagging log