Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -1508,8 +1508,7 @@ |
1509 | 1509 | $vars->setVar( 'old_wikitext', '' ); |
1510 | 1510 | } |
1511 | 1511 | |
1512 | | - $vars->addHolder( self::getEditVars( |
1513 | | - $title, $row->rc_this_oldid, $row->rc_last_oldid ) ); |
| 1512 | + $vars->addHolder( self::getEditVars( $title ) ); |
1514 | 1513 | |
1515 | 1514 | return $vars; |
1516 | 1515 | } |
— | — | @@ -1547,7 +1546,7 @@ |
1548 | 1547 | * @param $title Title |
1549 | 1548 | * @return AbuseFilterVariableHolder |
1550 | 1549 | */ |
1551 | | - public static function getEditVars( $title ) { |
| 1550 | + public static function getEditVars( $title, $article = null ) { |
1552 | 1551 | $vars = new AbuseFilterVariableHolder; |
1553 | 1552 | |
1554 | 1553 | $vars->setLazyLoadVar( 'edit_diff', 'diff', |
— | — | @@ -1568,7 +1567,8 @@ |
1569 | 1568 | array( |
1570 | 1569 | 'namespace' => $title->getNamespace(), |
1571 | 1570 | 'title' => $title->getText(), |
1572 | | - 'text-var' => 'new_wikitext' |
| 1571 | + 'text-var' => 'new_wikitext', |
| 1572 | + 'article' => $article |
1573 | 1573 | ) ); |
1574 | 1574 | $vars->setLazyLoadVar( 'old_links', 'links-from-wikitext-or-database', |
1575 | 1575 | array( |
— | — | @@ -1585,7 +1585,8 @@ |
1586 | 1586 | array( |
1587 | 1587 | 'namespace' => $title->getNamespace(), |
1588 | 1588 | 'title' => $title->getText(), |
1589 | | - 'wikitext-var' => 'new_wikitext' |
| 1589 | + 'wikitext-var' => 'new_wikitext', |
| 1590 | + 'article' => $article |
1590 | 1591 | ) ); |
1591 | 1592 | $vars->setLazyLoadVar( 'new_text', 'strip-html', |
1592 | 1593 | array( 'html-var' => 'new_html' ) ); |
Index: trunk/extensions/AbuseFilter/AbuseFilterVariableHolder.php |
— | — | @@ -224,26 +224,18 @@ |
225 | 225 | break; |
226 | 226 | case 'links-from-wikitext': |
227 | 227 | // This should ONLY be used when sharing a parse operation with the edit. |
228 | | - global $wgArticle; |
229 | 228 | |
230 | | - $article = self::articleFromTitle( |
231 | | - $parameters['namespace'], |
232 | | - $parameters['title'] |
233 | | - ); |
234 | | - |
235 | | - if ( $wgArticle && $article->getTitle()->equals( $wgArticle->getTitle() ) ) { |
| 229 | + $article = $parameters['article']; |
| 230 | + if ( $article ) { |
236 | 231 | $textVar = $parameters['text-var']; |
237 | 232 | |
238 | 233 | $new_text = $vars->getVar( $textVar )->toString(); |
239 | 234 | $editInfo = $article->prepareTextForEdit( $new_text ); |
240 | 235 | $links = array_keys( $editInfo->output->getExternalLinks() ); |
241 | 236 | $result = $links; |
242 | | - } else { |
243 | | - // Change to links-from-wikitext-nonedit. |
244 | | - $this->mMethod = 'links-from-wikitext-nonedit'; |
245 | | - $result = $this->compute( $vars ); |
| 237 | + break; |
246 | 238 | } |
247 | | - break; |
| 239 | + // Otherwise fall back to database |
248 | 240 | case 'links-from-wikitext-nonedit': |
249 | 241 | case 'links-from-wikitext-or-database': |
250 | 242 | $article = self::articleFromTitle( |
— | — | @@ -285,10 +277,9 @@ |
286 | 278 | break; |
287 | 279 | case 'parse-wikitext': |
288 | 280 | // Should ONLY be used when sharing a parse operation with the edit. |
289 | | - global $wgArticle; |
290 | | - $article = self::articleFromTitle( $parameters['namespace'], $parameters['title'] ); |
291 | | - |
292 | | - if ( $wgArticle && $article->getTitle() === $wgArticle->getTitle() ) { |
| 281 | + |
| 282 | + $article = $parameters['article']; |
| 283 | + if ( $article ) { |
293 | 284 | $textVar = $parameters['wikitext-var']; |
294 | 285 | |
295 | 286 | $new_text = $vars->getVar( $textVar )->toString(); |
— | — | @@ -297,12 +288,9 @@ |
298 | 289 | // Kill the PP limit comments. Ideally we'd just remove these by not setting the |
299 | 290 | // parser option, but then we can't share a parse operation with the edit, which is bad. |
300 | 291 | $result = preg_replace( '/<!--\s*NewPP limit report[^>]*-->\s*$/si', '', $newHTML ); |
301 | | - } else { |
302 | | - // Change to parse-wikitext-nonedit. |
303 | | - $this->mMethod = 'parse-wikitext-nonedit'; |
304 | | - $result = $this->compute( $vars ); |
| 292 | + break; |
305 | 293 | } |
306 | | - break; |
| 294 | + // Otherwise fall back to database |
307 | 295 | case 'parse-wikitext-nonedit': |
308 | 296 | $article = self::articleFromTitle( $parameters['namespace'], $parameters['title'] ); |
309 | 297 | $textVar = $parameters['wikitext-var']; |
Index: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php |
— | — | @@ -23,15 +23,16 @@ |
24 | 24 | // Check for null edits. |
25 | 25 | $oldtext = ''; |
26 | 26 | |
27 | | - if ( $editor->mArticle->exists() ) { |
| 27 | + $article = $editor->getArticle(); |
| 28 | + if ( $article->exists() ) { |
28 | 29 | // Make sure we load the latest text saved in database (bug 31656) |
29 | | - $oldtext = $editor->mArticle->getRevision()->getRawText(); |
| 30 | + $oldtext = $article->getRevision()->getRawText(); |
30 | 31 | } |
31 | 32 | |
32 | 33 | // Cache article object so we can share a parse operation |
33 | 34 | $title = $editor->mTitle; |
34 | 35 | $articleCacheKey = $title->getNamespace() . ':' . $title->getText(); |
35 | | - AFComputedVariable::$articleCache[$articleCacheKey] = $editor->mArticle; |
| 36 | + AFComputedVariable::$articleCache[$articleCacheKey] = $article; |
36 | 37 | |
37 | 38 | if ( strcmp( $oldtext, $text ) == 0 ) { |
38 | 39 | // Don't trigger for null edits. |
— | — | @@ -40,7 +41,7 @@ |
41 | 42 | |
42 | 43 | global $wgUser; |
43 | 44 | $vars->addHolder( AbuseFilter::generateUserVars( $wgUser ) ); |
44 | | - $vars->addHolder( AbuseFilter::generateTitleVars( $editor->mTitle , 'ARTICLE' ) ); |
| 45 | + $vars->addHolder( AbuseFilter::generateTitleVars( $title , 'ARTICLE' ) ); |
45 | 46 | $vars->setVar( 'ACTION', 'edit' ); |
46 | 47 | $vars->setVar( 'SUMMARY', $summary ); |
47 | 48 | $vars->setVar( 'minor_edit', $editor->minoredit ); |
— | — | @@ -48,9 +49,9 @@ |
49 | 50 | $vars->setVar( 'old_wikitext', $oldtext ); |
50 | 51 | $vars->setVar( 'new_wikitext', $text ); |
51 | 52 | |
52 | | - $vars->addHolder( AbuseFilter::getEditVars( $editor->mTitle ) ); |
| 53 | + $vars->addHolder( AbuseFilter::getEditVars( $title, $article ) ); |
53 | 54 | |
54 | | - $filter_result = AbuseFilter::filterAction( $vars, $editor->mTitle ); |
| 55 | + $filter_result = AbuseFilter::filterAction( $vars, $title ); |
55 | 56 | |
56 | 57 | if ( $filter_result !== true ) { |
57 | 58 | global $wgOut; |