[Tickets #5355] Re: Fix for PHP4 reference handling

bugs at bugs.horde.org bugs at bugs.horde.org
Tue May 15 08:01:47 UTC 2007


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=5355
-----------------------------------------------------------------------
 Ticket             | 5355
 Updated By         | thomas.jarosch at intra2net.com
 Summary            | Fix for PHP4 reference handling
 Queue              | Kronolith
 Version            | HEAD
 Type               | Bug
 State              | Feedback
 Priority           | 1. Low
 Owners             | 
-----------------------------------------------------------------------


thomas.jarosch at intra2net.com (2007-05-15 01:01) wrote:

Hello Chuck,

> I know you probably have, but did you test the Share change? There 
> have been problems in the past with assigning a reference to a static 
> variable in PHP 4. It may work if the static variable is an array, 
> instead of overwriting the static directly. But if you have:
>
> static $foo;
> ...
> $foo = &new Bar();
>
> Then the reference won't take.

Wow, I just modified my example code and it broke. Thanks for pointing
this out. The Horde_Share::singleton() code uses an array $shares, so it
should be ok. Works so far without problems here. I've changed this as the
new kolab share handler uses internal references between parent and child
objects.

> Also, this should only matter if, in the constructor, the class 
> creates a child object that needs to be assigned by reference. So I 
> think a lot of the places you added it in Kronolith are unnecessary. 
> Can you add new patches that only add the & where it fixes a problem 
> we're seeing?

Well, the new kronolith kolab driver uses an internal wrapper to switch
between the old and the new backend. This wrapper has a back-reference to
the Kronolith_Driver object, which breaks without the change. The problem
is you think its working, but you almost won't notice it and then strange
bugs occur when a variable inside the real driver object changed and you
still have an old copy of that object floating around.

If you want to you can skip the "FBview.php" and "Kronolith.php" part of
the patch
as it was only changed to make the fix complete. I've just checked all
static variables in Kronolith, looks good to me.

I'm still wondering a bit about Kronolith_Driver::factory(). The comment
states it should return a concrete instance of a driver, but as far as I
can see it always creates a new instance. Also take a look at
lib/Scheduler/kronolith.php. It creates a global driver object and then
creates another two. Is that supposed to happen?

Cheers,
Thomas




More information about the bugs mailing list