#3354 closed defect (bug) (fixed)
PHP 5.2 & Fatal error in cache.php
Reported by: | pulponair | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.2 | Priority: | normal |
Severity: | normal | Version: | 2.1.3 |
Component: | General | Keywords: | |
Focuses: | 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 (2)
Change History (46)
#2
@
18 years ago
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.
#3
@
18 years ago
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.
#4
@
18 years ago
That's weird, I can't do a double underline, that makes the text underlined. O well.
#5
@
18 years ago
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();
?>
#6
@
18 years ago
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(); ?>
#7
@
18 years ago
- Keywords needs-patch added
- 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.
#8
@
18 years ago
What milestone will contain this patch? I am curious because my website is severely hindered by this bug.
#10
@
18 years ago
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?
#11
@
18 years ago
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
#12
in reply to:
↑ 9
@
18 years ago
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
#15
@
18 years ago
This item still isn't fixed. I tried RC2 on a Windows 5.2 server and still have issues chocking on the get function.
#16
@
18 years ago
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
#18
@
18 years ago
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.
#20
@
18 years ago
- 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
#22
@
18 years ago
- 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
#23
follow-up:
↓ 24
@
18 years ago
- Keywords needs-testing added; needs-patch removed
#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)
#24
in reply to:
↑ 23
@
18 years ago
- Keywords needs-testing removed
Replying to foolswisdom:
Oops, that comment was meant for ticket:3528
#25
@
18 years ago
The fix would be nice in WP 2.0.7. Many hosts have been upgrading php installations lately.
#27
@
18 years ago
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?
#28
@
18 years ago
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
#32
@
18 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
- Version changed from 2.0.5 to 2.1.1
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?
#33
@
18 years ago
- 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?
#35
@
18 years ago
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.
#37
@
18 years ago
- Resolution set to fixed
- Status changed from reopened to closed
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.
#38
@
17 years ago
- Resolution fixed deleted
- Severity changed from blocker to normal
- Status changed from closed to reopened
- Version changed from 2.1.1 to 2.1.3
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...
#40
@
17 years ago
Patch makes sure output buffers started by plugins are shutdown before objects are destroyed.
#43
in reply to:
↑ 21
@
15 years ago
Replying to ryan:
[4686] tries some of the destruct tricks.
Maybe the trick here was that while using register_shutdown_function the object will never be destroyed because the callback still uses it (and therefore it will exist until the very end of the script).
Return true;
on a __destruct()
magic function does nothing as far as I know.
See http://bugs.php.net/bug.php?id=39381