6.0.0-alpha12
6/8/25

[#5355] Fix for PHP4 reference handling
Summary Fix for PHP4 reference handling
Queue Kronolith
Queue Version HEAD
Type Bug
State Resolved
Priority 1. Low
Owners chuck (at) horde (dot) org
Requester thomas.jarosch (at) intra2net (dot) com
Created 05/14/2007 (6600 days ago)
Due
Updated 05/25/2007 (6589 days ago)
Assigned 05/14/2007 (6600 days ago)
Resolved 05/17/2007 (6597 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
05/25/2007 04:42:56 PM Chuck Hagenbuch Comment #9 Reply to this comment
Committed, thanks.
05/25/2007 09:58:54 AM thomas (dot) jarosch (at) intra2net (dot) com Comment #8
New Attachment: framework-share-reference-fix2.patch Download
Reply to this comment
I've done another round of reference fixing and here is the result. We 
didn't want to commit it directly to CVS, so please have a look. I 
hope it's the last patch in this area :-)


05/17/2007 07:49:14 PM Chuck Hagenbuch Comment #7
State ⇒ Resolved
Assigned to Chuck Hagenbuch
Reply to this comment
The fixes are committed now, thanks.
05/17/2007 07:47:46 PM Chuck Hagenbuch Comment #6 Reply to this comment
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.
That's the behavior of a factory - it turns a string into a concrete 
object. Probably not the clearest behavior in the world but it's 
behaving correctly.
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?
Doubtful. :)
05/15/2007 08:01:47 AM thomas (dot) jarosch (at) intra2net (dot) com Comment #5 Reply to this comment
Hello Chuck,

[Show Quoted Text - 10 lines]
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


05/14/2007 07:28:24 PM Chuck Hagenbuch Comment #4
State ⇒ Feedback
Reply to this comment
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.



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?



Thanks!
05/14/2007 01:34:22 PM thomas (dot) jarosch (at) intra2net (dot) com Comment #3
New Attachment: framework-share-reference-fix.patch Download
Reply to this comment
Fix for Horde_Share.


05/14/2007 01:33:52 PM thomas (dot) jarosch (at) intra2net (dot) com Comment #2
New Attachment: kronolith-fix-references.patch Download
Reply to this comment
Fix for kronolith
05/14/2007 01:33:27 PM thomas (dot) jarosch (at) intra2net (dot) com Comment #1
Priority ⇒ 1. Low
State ⇒ Unconfirmed
New Attachment: reference_test_case.php Download
Queue ⇒ Kronolith
Summary ⇒ Fix for PHP4 reference handling
Type ⇒ Bug
Reply to this comment
Hello together,



while developing the new Kolab driver for kronolith I found out that 
the reference handling in PHP4 is somewhat messed up. I've written a 
small test case to demonstrate the problem. Attached you'll find a fix 
for Kronolith and one for Horde_Share.



Cheers,

Thomas


Saved Queries