https://bugzilla.wikimedia.org/show_bug.cgi?id=18165
Andrew Garrett <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #3 from Andrew Garrett <[email protected]> 2009-03-26 04:09:28 UTC --- (In reply to comment #2) > (In reply to comment #1) > > The function cache is a static variable, and therefore not cleared. > > By declaring it static you create a globally accessible variable > AbuseFilterParser::$funcCache, that has one value, but every instance of the > class has it's own instantiation of $funcCache that is separate from the > global > variable and separate from each other. > > So strictly speaking you didn't clear it, rather by calling new you created a > new one that is blank. > > Test this yourself. $funcCache is not retained across rules. I did: > $afp = new AbuseFilterParser(); > $afp->evaluateExpression( 'ccnorm("FooBarBaz")' ) > print_r( AbuseFilterParser::$funcCache ); Array ( [8437e92172f797748a5f891b6952c110] => AFPData Object ( [type] => string [data] => F00BARBAZ ) ) > $afp = new AbuseFilterParser(); Seems to work for me. > > The variable holder is not being reset to its original state. It's an > > object, > > so it's passed by reference, so you'd need specific code to reset it to its > > original state. > > You have such code. More precisely, each time AbuseFilterParser is created it > in turn creates a new AbuseFilterVariableHolder and then calls addHolder to > copy the parameters passed to it in setVars. Those parameters consist of an > array of AFPData and AFPComputedVariable objects. During the course of > operation you replace the AFPComputedVariable objects which AFPData objects as > you fetch the values. > > The problem here is that because you copied the array into a local holder, and > didn't simply attach the original VariableHolder by reference, that means that > the data array in the original VariableHolder is unaware of the actions > occuring in the local copy. Specifically, it doesn't know that you replaced > ComputedVariables with Data. > > So each time you create a new parser you end up passing it the original > VariableHolder that still contains the unprocessed ComputedVariables. You're right here, and I've made the Parser a lazy-initialised static variable in r48855. -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
