PHP Warning on /wp-cache-phase2.php
-
Anyone else getting this PHP warning?
PHP Warning: Attempt to read property “ID” on int in /wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 3411′
-
Hi @dwxd,
Thanks for reaching out! Could you share a few details to help us investigate?
- WordPress and PHP versions
- WP Super Cache version
- Any recent changes to your site (updates, new plugins, etc.)
Let me know so we can look into this further!
Hi @alinclamba,
Thanks for getting back to me on this.
PHP Version: 8.3.7
WordPress Version: 6.6.2
WP Super Cache Version: 1.12.4The main change we have done recently was update to the latest version of PHP, however this warning isn’t getting shown on our other sites which are using the same PHP version, so can’t be that?
We’ve uninstalled the plugin and re-installed it with a fresh clean set of instructions, but still is coming up with the warning unfortunately.
Maybe you can go into details into what this file is/does?
/wp-cache-phase2.php
Thanks
It’s in a function called wp_cache_post_id() which should return the ID of the post being displayed. Do you see this warning happen when you’re displaying single posts?
Are you modifying the global $posts variable on this website? The line that’s causing the warning uses that variable.
It might be worth investigating that bit of code by dumping $posts to error_log() to make sure it does have “$posts[0]->ID”.
Hi there, @dwxd,
Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!
Hi @donncha and @erania-pinnera,
We are still getting this strange error ??
We are not modifying the global $posts variable.
After dumping the $posts array, the ID is always getting populated, here is the full array in-case you can spot anything else going on which WP Super Cache might not like:
array(1) { [0]=> object(WP_Post)#2504 (24) { ["ID"]=> int(24137) ["post_author"]=> string(2) "12" ["post_date"]=> string(19) "2024-05-08 12:58:11" ["post_date_gmt"]=> string(19) "2024-05-08 11:58:11" ["post_content"]=> string(0) "" ["post_title"]=> string(55) "Apple's New iPad Pro - The Ultimate Portable Powerhouse" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(4) "open" ["post_password"]=> string(0) "" ["post_name"]=> string(52) "apples-new-ipad-pro-the-ultimate-portable-powerhouse" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2024-06-13 14:56:45" ["post_modified_gmt"]=> string(19) "2024-06-13 13:56:45" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(38) "https://www.loveitcoverit.com/?p=24137" ["menu_order"]=> int(0) ["post_type"]=> string(4) "post" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } }
Also from my understanding this is only going to impact the single.php? “blog” section and not the main “pages” (page.php) section of our website?
Thanks
Thanks for checking. It should only happen on single posts on your website, but that can include pages. It won’t happen on archive pages or your homepage.
Did you see the error_log dump out that sort of array at the same time the warning showed in your error_log? Does the warning happen very often? I think it would be worth including the URL in the error_log too ($_SERVER[‘REQUEST_URI’]) so you’ll know what page the problem is happening on. It might well be a plugin or your theme interacting with the posts array on a particular page that’s causing the problem.
Hey @dwxd,
Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!
Hey @erania-pinnera,
Sorry, yes we are still seeing this issue happening, and trying to pin point exactly what is going on.
On our development site i am testing out more of a error handler to get more information as suggested, hopefully be able to put this in place on our production environment soon to nail this.
I’ll let you know what this tells me.
Out of curiosity, this seems like a “only us” kind of bug, has anyone else flagged something similar to this in the past?
Thanks
Hello there,
?
Sebastian from Jetpack here. I hope you are doing well.It seems like this issue might be specific to your setup, as we cannot find any other reports of this.
It’s a good idea to continue with the error handler to gather more information. Including the URL in the error log, as suggested, can help identify if a specific page or plugin is causing the issue.
Please keep us updated on your findings.
Thank you!
Hi there @dwxd,
Do you have any more news to share with us? How did the further testing go?
As mentioned, we usually close threads after one week of inactivity ??
- You must be logged in to reply to this topic.