Index: trunk/extensions/DidYouMean/DidYouMean.hooks.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | * All the hooks for DidYouMean |
5 | 5 | */ |
6 | 6 | class DidYouMeanHooks { |
| 7 | + private static $articleIsRedirect = false; |
7 | 8 | |
8 | 9 | # TODO this is called even when editing a new page |
9 | 10 | public static function articleNoArticleText( &$article, &$text ) { |
— | — | @@ -142,34 +143,34 @@ |
143 | 144 | |
144 | 145 | # called at action=edit. can detect if we're about to edit a redirect |
145 | 146 | 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; |
152 | 152 | } |
153 | | - |
| 153 | + |
154 | 154 | # called at end of action=submit |
155 | 155 | 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 ) { |
159 | 157 | 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 ) ) { |
163 | 162 | DidYouMean::doDelete( $article->getID() ); |
| 163 | + } |
164 | 164 | } else { |
165 | | - if (!empty( $wgParser->mDymRedirBeforeEdit ) || $flags & EDIT_NEW) |
| 165 | + if ( self::$articleIsRedirect || $flags & EDIT_NEW ) { |
166 | 166 | DidYouMean::doInsert( $article->getID(), $article->getTitle()->getText() ); |
| 167 | + } |
167 | 168 | } |
168 | | - |
169 | | - $wgParser->mDymRedirBeforeEdit = false; |
170 | | - |
| 169 | + |
| 170 | + self::$articleIsRedirect = false; |
| 171 | + |
171 | 172 | return true; |
172 | 173 | } |
173 | | - |
| 174 | + |
174 | 175 | public static function articleUndelete( &$title, &$create ) { |
175 | 176 | |
176 | 177 | if ($create == false || $title->getNamespace() != 0) |