Ticket #3354 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

PHP 5.2 & Fatal error in cache.php

Reported by: pulponair Assigned to: ryan
Priority: normal Milestone: 2.2
Component: General Version: 2.1.3
Severity: normal Keywords:
Cc:

Description

Since upgrading to php 5.2 i am constantly recieving the following error:

PHP Fatal error: Call to a member function get() on a non-object in /var/www/xyz/htdocs/wp-includes/cache.php on line 28.

This may be related to the object module changes applied in 5.2 since everthing worked fine using 5.1.6. The error occurs when surfing wordpress without beeing logged in.

Attachments

openid2.patch (0.8 kB) - added by hvdkamer on 04/19/07 18:27:50.
Fix to correct problem in cache.php
shutdown.diff (1.0 kB) - added by ryan on 05/12/07 04:34:56.

Change History

11/18/06 23:56:16 changed by ryan

11/20/06 19:16:37 changed by pulponair

Temporary fix :

wp-includes/cache.php Line 28:

    if (!is_object($wp_object_cache)) {
    $wp_object_cache = new WP_Object_Cache();
    }

wp-includes/cache.php Line 187:

    if (!is_object($wpdb)) {
    $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    }

quick n dirty but working.

12/02/06 13:45:07 changed by darkfate

Yeah, damn deconstuct. They marked the bug as bogus (even though it technically isnt), so I don't think it's getting fixed in the PHP. You can sorta fix it by calling register_shutdown_function on destruct, but destruct is still messed up. Although it gets rid of the error.

12/02/06 13:46:38 changed by darkfate

That's weird, I can't do a double underline, that makes the text underlined. O well.

12/02/06 13:51:38 changed by darkfate

You can also call destruct as a function in a class: <?php class Destruct {

function Destruct() {

return $this->construct(); // forward php4 to construct

}

function construct() {

// register destruct method as shutdown function register_shutdown_function(array(&$this, "destruct"));

return true;

}

function destruct() {

// finish stuff return true;

}

}

$obj = new Destruct(); ?>

12/02/06 13:55:41 changed by darkfate

We need an editing function:

<?php 
class Destruct {

    function Destruct() {

        return $this->__construct(); // forward php4 to construct

    }

    function __construct() {

        // register destruct method as shutdown function
        register_shutdown_function(array(&$this, "__destruct"));

        return true;

    }

    function __destruct() {

        // finish stuff 
        return true;

    }

}

$obj = new Destruct(); 
?>

12/04/06 12:18:04 changed by markjaquith

  • keywords set to needs-patch.
  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.

5.2 is stable and this bug doesn't seem to be getting any traction on the PHP bug tracker, so this needs a patch.

12/11/06 08:40:11 changed by pzuidhoek

What milestone will contain this patch? I am curious because my website is severely hindered by this bug.

(follow-up: ↓ 12 ) 12/11/06 08:45:26 changed by ryan

Can you try out the 2.0.6 beta and let us know if it helps?

http://wordpress.org/beta/wordpress-2.0.6-beta1.zip

12/11/06 21:19:13 changed by markjaquith

I've had access to a PHP 5.2 system, and haven't been able to trigger this error. We're going to need more information about how it is triggered. The reporter said "constantly" and "when surfing wordpress without being logged in." Does that mean on every hit? On certain types of actions or page views? Sporadically without rhyme or reason?

12/11/06 21:36:42 changed by ryan

I put php 5.2 on my system and I don't see any problems either.

Apache/2.0.55 (Ubuntu) mod_fastcgi/2.4.2 PHP/5.2.0-0.dotdeb.3 with Suhosin-Patch mod_ssl/2.0.55 OpenSSL/0.9.8b configured

(in reply to: ↑ 9 ) 12/15/06 02:15:57 changed by pzuidhoek

Ryan,

I did not have enought time to try out the full beta, but I merged the changes in cache.php and wp-settings.php. It did the job.

Peter

12/26/06 09:00:36 changed by shorty114

Can we mark this as fixed then?

12/26/06 09:00:59 changed by shorty114

  • milestone set to 2.0.6.

01/01/07 22:19:11 changed by Mike_Koepke

This item still isn't fixed. I tried RC2 on a Windows 5.2 server and still have issues chocking on the get function.

01/05/07 08:51:20 changed by markjaquith

We'll consider this as one of the first things to tackle for 2.0.7, but we really need to get 2.0.6 out the door.

Also, is this an issue with Trunk? If so, it should probably be tackled for 2.1

01/05/07 08:51:30 changed by markjaquith

  • milestone changed from 2.0.6 to 2.0.7.

01/05/07 13:46:33 changed by Mike_Koepke

I tried it this morning with PHP 5.2.1-RC2 on a Windows XP system with 2.0.5. The problem still exists. The only way to get it working is to apply the cache.php quick and dirty fixes above. I will try again with 2.0.6 when it is released.

01/05/07 19:20:23 changed by kelson

This still happens in WordPress 2.0.6.

PHP 5.2.0 on Linux.

01/06/07 10:06:50 changed by markjaquith

  • owner changed from markjaquith to ryan.
  • status changed from assigned to new.

Ryan's the big PHP guru, so I'm handing this one off. This likely needs fixing for both 2.1 and 2.0.7

01/06/07 23:39:12 changed by ryan

[4686] tries some of the destruct tricks.

01/10/07 13:55:12 changed by markjaquith

  • milestone changed from 2.0.7 to 2.1.

2.0.7 is too soon for this... lets see how it goes for 2.1 and then consider for 2.0.8

(follow-up: ↓ 24 ) 01/10/07 19:18:32 changed by foolswisdom

  • keywords changed from needs-patch to needs-testing.

#wordpress-dev (02:27:48 AM) io_error: Otherwise it fails on PHP < 4.3.5 and/or if cgi.rfc2616_headers is set (it's off by default)

(in reply to: ↑ 23 ) 01/10/07 19:30:32 changed by foolswisdom

  • keywords deleted.

Replying to foolswisdom:

Oops, that comment was meant for ticket:3528

01/11/07 22:18:19 changed by Denis-de-Bernardy

The fix would be nice in WP 2.0.7. Many hosts have been upgrading php installations lately.

01/11/07 22:26:06 changed by Denis-de-Bernardy

The bug also gets worse when a function anywhere uses an output buffer.

D.

01/12/07 03:10:32 changed by markjaquith

I'm cautious with any fix that is described with the word "tricks" ;-)

We have a bunch of tickets slated for 2.0.8, so a fix of some sort will go in soon. We just want 2.0.7 to basically be "2.0.6.1"

Denis, can I take your comment to mean that you've tested this fix and verified that it solves the problem?

01/12/07 22:58:15 changed by Denis-de-Bernardy

The suggested fix worked on my laptop, yes. But inserting this in function.php did so as well:

# fix php 5.2

if ( !function_exists('ob_end_flush_all') ) :
function ob_end_flush_all()
{
	while ( @ob_end_flush() );
}

register_shutdown_function('ob_end_flush_all');
endif;

I was only getting the bug when I was using output buffers. Forcing the output buffer to flush before the shutdown occurs (and thus before variables are destroyed) fixed this issue and many others I was getting.

Please be so kind to keep the conditional wrapper if you decide to use the above code. I'd hate to end up with function name collisions with my own scripts.

Denis

01/12/07 23:18:27 changed by Denis-de-Bernardy

my php bug report doesn't seem to interest them...

http://bugs.php.net/bug.php?id=40104

01/16/07 01:19:12 changed by ryan

  • milestone changed from 2.1 to 2.0.8.

01/30/07 18:33:50 changed by markjaquith

  • status changed from new to closed.
  • resolution set to fixed.

(In [4841]) Fiddle with object destruction and shutdown. Curses upon php 5.2. fixes #3354

02/21/07 18:21:51 changed by kelson

  • status changed from closed to reopened.
  • version changed from 2.0.5 to 2.1.1.
  • resolution deleted.

I still see this on WordPress 2.1.1 with PHP 5.2.1:

"PHP Fatal error: Call to a member function get() on a non-object in /path/to/wp-includes/cache.php on line 32"

And it still stops processing single-post pages before displaying the comments area.

Was this only fixed in the 2.0 series?

02/24/07 17:01:08 changed by rob1n

  • milestone changed from 2.0.8 to 2.1.2.

It appears the fix only went into the 2.0 branch, yes.

Ryan: Can we put this in 2.1 and 2.2 SVN?

02/25/07 02:44:52 changed by ryan

It's already in both 2.1 and 2.2. [4686]

03/06/07 00:40:27 changed by darkfate

This may be a user specific issue. If the temp directory isn't setup correctly, you'll get errors caching files. Say you set the temp folder to C:\Temp. If there is no Temp folder, it totally goes beserk.

03/28/07 00:58:56 changed by foolswisdom

  • milestone changed from 2.1.3 to 2.2.

04/12/07 06:10:05 changed by rob1n

  • status changed from reopened to closed.
  • resolution set to fixed.

Well, then it's an user misconfiguration error. We've fixed it as much as we can. If the user has a misconfigured server, well, then that's their fault and mistake.

04/19/07 18:27:02 changed by hvdkamer

  • status changed from closed to reopened.
  • version changed from 2.1.1 to 2.1.3.
  • resolution deleted.
  • severity changed from blocker to normal.

After installing the wpopenid plugin I got the following error:

[19-Apr-2007 15:50:15] PHP Fatal error:  Call to a member function get() on a non-object in /var/www/hetlab.tk/www/wp-includes/cache.php on line 32

I'm using WordPress 2.1.3 on PHP 5.2.0-8+etch1 from Debian and /tmp is correct. After applying the fix by pulponair in the second post of this thread, the error was gone and the wpopenid plugin worked. I will try to attach my diff...

04/19/07 18:27:50 changed by hvdkamer

  • attachment openid2.patch added.

Fix to correct problem in cache.php

05/12/07 03:16:11 changed by ryan

hvdkamer, does Denis patch work for you? I think that is a better fix if so.

http://trac.wordpress.org/ticket/3354#comment:28

05/12/07 04:34:56 changed by ryan

  • attachment shutdown.diff added.

05/12/07 04:35:27 changed by ryan

Patch makes sure output buffers started by plugins are shutdown before objects are destroyed.

05/12/07 22:06:31 changed by ryan

(In [5462]) Flush all output buffers during shutdown to avoid PHP 5 bustage. see #3354

05/12/07 22:37:07 changed by ryan

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [5463]) Flush all output buffers during shutdown to avoid PHP 5 bustage. fixes #3354 for 2.2