r48855 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48854‎ | r48855 | r48856 >
Date:04:09, 26 March 2009
Author:werdna
Status:ok (Comments)
Tags:
Comment:
(bug 18165) Keep the same parser object between filter runs
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -339,12 +339,17 @@
340340 public static function checkConditions( $conds, $vars, $ignoreError = true ) {
341341 global $wgAbuseFilterParserClass;
342342
 343+ static $parser;
 344+
343345 wfProfileIn( __METHOD__ );
344346
345 - try {
 347+ if ( is_null($parser) ) {
346348 $parser = new $wgAbuseFilterParserClass;
347349
348350 $parser->setVars( $vars );
 351+ }
 352+
 353+ try {
349354 $result = $parser->parse( $conds, self::$condCount );
350355 } catch (Exception $excep) {
351356 // Sigh.

Follow-up revisions

RevisionCommit summaryAuthorDate
r48856Fix batch-testing (follow-up to r48855)werdna04:41, 26 March 2009

Comments

#Comment by Tim Starling (talk | contribs)   06:17, 20 May 2009

You should move it to somewhere more accessible, like a static member variable. Objects like these always end up being accessed from other places, eventually.

Status & tagging log