From 334582b645181354d4723bc30618a19c4ef3769e Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Mon, 16 Mar 2009 08:21:24 +0000 Subject: [PATCH] Fix weird bug occurring in corrupted databases. --- AbuseFilter.parser.php | 26 +++++++++++++++++++++++++- AbuseFilterVariableHolder.php | 5 +++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/AbuseFilter.parser.php b/AbuseFilter.parser.php index 5836de168..898d067d1 100644 --- a/AbuseFilter.parser.php +++ b/AbuseFilter.parser.php @@ -288,7 +288,7 @@ class AFPUserVisibleException extends AFPException { } class AbuseFilterParser { - var $mParams, $mVars, $mCode, $mTokens, $mPos, $mCur; + var $mParams, $mVars, $mCode, $mTokens, $mPos, $mCur, $mSubexpressions, $mDebug; // length,lcase,ccnorm,rmdoubles,specialratio,rmspecials,norm,count static $mFunctions = array( @@ -341,6 +341,8 @@ class AbuseFilterParser { $this->mTokens = array(); $this->mVars = new AbuseFilterVariableHolder; $this->mPos = 0; + $this->mDebug = false; + $this->mSubexpressions = array(); } public function checkSyntax( $filter ) { @@ -411,6 +413,28 @@ class AbuseFilterParser { return ( strlen($a) < strlen($b) ) ? -1 : 1; } + protected function createSubexpression( $value, $tokens, $type = null ) { + if ($type) + $data = new AFPData( $type, $value ); + else + $data = AFPData::newFromPHPVar( $value ); + + if (!$this->mDebug) + return $data; + + if (!$this->mSubexpressions) + $this->mSubexpressions = array(); + + $thisData = array( + 'tokens' => $tokens, + 'value' => $data, + ); + + $this->mSubexpressions[] = $thisData; + + return $data; + } + /* Levels */ /** Handles unexpected characters after the expression */ diff --git a/AbuseFilterVariableHolder.php b/AbuseFilterVariableHolder.php index 96cdb437b..5e5d64388 100644 --- a/AbuseFilterVariableHolder.php +++ b/AbuseFilterVariableHolder.php @@ -218,6 +218,11 @@ class AFComputedVariable { $cutOff = $parameters['cutoff']; $title = Title::makeTitle( $parameters['namespace'], $parameters['title'] ); + if (!$title->exists()) { + $result = ''; + break; + } + $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'revision', 'distinct rev_user_text', array(