https://bugzilla.wikimedia.org/show_bug.cgi?id=20036





--- Comment #3 from Tim Starling <[email protected]>  2009-08-04 03:13:14 
UTC ---
The clone operation in PHP is a shallow copy, it copies member object handles
instead of whole objects. So this:

$a = (object)array( 'm' => (object)array('n' => 1) );
$b = clone $a;
$a->m->n = 2;
print $b->m->n;

will print "2". It's basically equivalent to assigning each member variable in
turn:

$b = new stdclass;
$b->m = $a->m;

This means that if you do this from a tag hook:

$parser = clone $wgParser;
$lineStart = true;
$clearState = false;
$parser->parse($text, $title, $options, $lineStart, $clearState);

then you mess up the state of any child objects that $wgParser was storing. I
think the reporter is triggering this total destruction of parser state from an
extension, and misdiagnosing the result.

If so, I think this is a WONTFIX. I used to recommend cloning the parser but
it's since become obvious that it's a really bad idea, especially after MW
1.12. You can do it if you call clearState(), wiping out any problematic
objects, that's basically how MessageCache manages it. But you can't just call
random functions and expect them to work. My current thinking on this is that
cloning should be replaced with calls to appropriate re-entrant functions, such
as recursiveTagParse(). 


-- 
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

Reply via email to