Re: Bug Fix
Arnaud Limbourg <arnaud-GdXxm9JVFPlWk0Htik3J/[email protected]> Thu, 27 Oct 2005 07:26:04 +0200
| Newsgroups | gmane.comp.php.pear.liveuser |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I just caught this yesterday and forgot to post a message to the list.
I modified the test but now that you mention it I don't really
understand why this code would do that, I'll wait for Lukas' input.
Arnaud.
Balarama Bosch wrote:
> Hi,
>
> Found a bug that was annoying the hell out of me.
> I was trying to add some custom logs through the conf array...
>
> in LiveUser.php 0.16.7 line 679
>
> function readConfig(&$conf)
> {
> // probably a futile attempt at working out reference issues in arrays
> $options = $conf;
> unset($options['debug']);
>
> if (array_key_exists('debug', $conf) && is_object($conf['debug'])) {
> $options['debug'] = true;
> }
>
> On line 682 a copy of $conf is made. The problem is that the references
> are still the SAME references as in the original object. From a comment
> in the PHP manual: On array copying a deep copy is done of elements
> except those elements which are references, in which case the reference
> is maintained. This is a very important thing to understand if you
> intend on mixing references and recursive arrays.
>
> To get around that, before you change the value of $options['debug'] you
> need to unset it, so it won't change the referenced object.
> So add under line 682:
>
> unset($options['debug']);
>
> Hope this helps.
>
> Cheers,
> Balarama Bosch