I’m deeply confused by this one: I have a WordPress install on a Media Temple GS [one of many which work fine and are configured almost exactly the same] which is occasionally giving me 404s sitewide. When this happens I get 3 errors together in my PHP error log:
[01-Nov-2013 22:20:50 UTC] PHP Notice: Trying to get property of non-object in /nfs/---/---/mnt/---/domains/---.---/html/wp-includes/post-template.php on line 275
[01-Nov-2013 22:20:50 UTC] PHP Notice: Trying to get property of non-object in /nfs/---/---/mnt/---/domains/---.---/html/wp-includes/post-template.php on line 209
[01-Nov-2013 22:20:50 UTC] PHP Notice: Trying to get property of non-object in /nfs/---/---/mnt/---/domains/---.---/html/wp-includes/post-template.php on line 29
The first two relate to the $post
object & the 3rd to this: get_post()->ID;
Which I think is the creation of the $post
object.
I have two of these identical trios of error messages almost exactly 25 minutes apart [off by 2s].
I’ve tried MT support but they think it must be a WP error. I’m running the latest version of WP but have experienced this problem with earlier versions.
I had 2 plugins enabled: W3 Total Cache & AJAX Thumbnail Rebuild
I’ve tested with and without the cache plugin and the problem persists. I’ve just disabled the thumbnail plug to see if it makes any difference.
Please help this is driving me insane! [and I wanted to publicly launch this site today]
EDIT
I should have also mentioned that I have seen this error on some but not all of the other wordpress installs on this server. I think but cannot be 100% sure, that those showing errors are newer installs than the ones working fine. Though all installs are fully updated.
EDIT2
I’m just working on another WP project and realised at least what those 3 errors mean. I can reproduce exactly those three php errors by going to the index page of a custom post type that does not exist. However this doesn’t explain why that would cause the 404 in this question, especially as it doesn’t just happen only on custom post type index pages. However I think this must be related to custom post types in some way.
There are two types of 404 errors: WordPress-generated, and server-generated.
In some server environments, 404s could be inaccurately displayed by the server in cases of CPU overload or due to certain instances of misconfiguration, etc. Usually server-generated 404 errors will say something like “Nginx” or “Apache” at the bottom of the page (depends on server type).
In other situations, “false positive” 404 errors could be generated by WordPress (PHP) because security plugins are blocking access to loaded resources:
Why am I sometimes getting a 404 error when I try to update a page with Elementor?
https://wordpress.org/support/topic/getting-false-positive-404-errors-with-newest-update/
Try disabling any security plugins, clear caches, and refresh the page. Security modules such as ModSecurity installed on your server could also potentially be the cause.
It could also be caused by a poorly coded theme or plugin. Check if there’s a common theme or plugin installed on all the sites involved. And if this issue only occurs on Media Temple hosting, it’s possible they have something misconfigured, or even that your server is under too much load…
You have not enough information to solve your problem. Try to add full stack trace and request information to your error log to investigate an issue.
You can create your own custom error handler to add stack trace and request information to your error log.
You can check if this is working by adding trigger_error somewhere in your code e.g in
single.php
file.Your error log should output something like that:
With this kind of message it will be much easier to find out where the problem is.