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

--- Comment #21 from Brad Jorsch <[email protected]> ---
I've figured out a minimal test case for this:

 $object = new stdclass;
 $object->v = 1;

 $foo = &$object->v;

 $myObj = clone $object;
 $myObj->v = 2;

 echo "object->v is {$object->v}\n";

What's going on here is that the existence of the reference in $foo is making
$object->v *also* be considered a reference. And so the clone is copying the
reference as a reference, so the later assignment overwrites the original.

I don't think the PHP developers would consider this a bug, given the
explanation at
http://php.net/manual/en/language.references.whatdo.php#language.references.whatdo.assign
that basically says there's no "from" and "to" when it comes to PHP references.


(In reply to Bawolff (Brian Wolff) from comment #8)
> I have no idea how or why, but updated patch which stops issue occurring by
> doing something that really should have no affect whatsoever. Specificly it
> does:
> 
> $foo = new StripState( $stuff );
> $this->mStripState =& $foo;

The difference between that and direct assignment is that that rebinds
$this->mStripState as a reference to $foo, rather than assigning a new value to
the existing reference.

-- 
You are receiving this mail because:
You are the assignee for the bug.
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