Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    1,649
    Plugin Contributions
    2

    Default workaround for php5.2 issue

    I saw at least another thread discussing this, but none under "code matters" (and none containing a good solution IMO), and I wanted to make sure this is read by the right people so I decided to submit a bug report.

    Call to a member function Execute() on a non-object in ...includes\functions\sessions.php on line 61
    According to http://www.php.net/session_set_save_handler, session "Write and Close handlers are called after destructing objects since PHP 5.0.5". Why this was not a problem in ZC and other scripts between PHP 5.0.5 and 5.2 I don't know, and I can't say I'm much wiser after skimming through the PHP changelog either because some of the bugs that were fixed in PHP5.2 (that could be related to this issue) were not well described.

    Anyway, the problem is that ZC won't work properly with custom session handler (db) in PHP5.2, and the reason seems to be (assuming I've got the facts right) that objects are destroyed before the session is written, as stated in the PHP manual and quoted above. In other words, the $db object, which is needed by the custom db session handler, won't be available to the session save and close handlers.

    I saw another workaround for PHP5.2 mentioned somewhere in these forums that instantiated a new $db object in the custom session write handler, but that's not necessary if the session is written and closed before objects are destructed, and that can be accomplished by calling session_write_close() at script shutdown, ie.
    Code:
    register_shutdown_function('session_write_close');
    The above line should be called whenever session_set_save_handler() is called (and the session write handler makes use of objects), so I'll suggest a wrapper function.
    Code:
    function zc_session_set_save_handler ($open, $close, $read, $write, $destroy, $gc)
    {
    	if (session_set_save_handler($open, $close, $read, $write, $destroy, $gc) === false)
    	{
    		return false;
    	}
    	# write and close session at the end of script, and before objects are destroyed (required for PHP5.2)
    	register_shutdown_function('session_write_close');
    	return true;
    }
    and replace calls to session_set_save_handler() with zc_session_set_save_handler().
    Last edited by dwno; 17 Jan 2007 at 10:00 PM.

  2. #2
    Join Date
    Apr 2006
    Location
    Sydney, Australia
    Posts
    112
    Plugin Contributions
    0

    Default Re: workaround for php5.2 issue

    probably the first time I have felt quite inadequate on these forums as I got a bit lost on this one.

    It is likely this is the issue affecting my site but not totally sure I can make the change without f***** it all up.
    alfo

    www.alfo.com.au
    online ordering for catering, tea parties, take away food and retail from alfo cafe
    www.alifefullof.com.au
    tea party essentials: leaf tea, coffee beans, oils, chocolate and more

  3. #3
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: workaround for php5.2 issue

    The 'problem' is actually with PHP 5.2.x and affects many scripts/functions.

    As per: http://bugs.php.net/bug.php?id=39381

    This is a PHP 5.2.0 error which causes the classes to be destructed in
    the reverse way they are initialized. If this change was intended for
    PHP 5.2.0, then you should have given us a heads up before you went
    releasing software that broke a whole ton of scripts.
    This IS a error on PHP 5.2.0, the PHP team should consider unbogusing
    the report.


    I had read elsewhere that using Zend 3.2.2 was supposed to fix or help with the problem. Testing has confirmed this is not true. Further testing showed any version of PHP previous to 5.2.x, and using any version of Zend, does not have this problem.

    If your Hoster is using PHP 5.2.x then one could use the solution as posted above by dwno, or the fix supplied by DrByte, which has been confirmed to fix the problem.

 

 

Similar Threads

  1. Where do I find the PHP5 workaround?
    By plymgary1 in forum General Questions
    Replies: 2
    Last Post: 4 Jan 2010, 04:25 PM
  2. PCI compliancy issue & php5.2.10?
    By stride-r in forum Installing on a Windows Server
    Replies: 6
    Last Post: 22 Aug 2009, 11:23 PM
  3. Workaround for Resellers/Tax Exempt
    By sarahbn in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 5
    Last Post: 26 Jun 2009, 08:13 PM
  4. Workaround for QuickBooks with two state tax amounts?
    By d0ugparker in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 15 Jun 2009, 03:03 PM
  5. Best Workaround For Multiple Coupons?
    By trackerkbc in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 5 Aug 2006, 03:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR