Errors found in php error log

Site: ElisabettaC77

Expected behavior

The PHP error log should show no errors or notices

Current behavior

Theme: Twenty8teen

Plugins:

  • Classic SEO Version 1.0.0-beta.2
  • Fluent Form Version 3.2.4
  • Insert Headers and Footers Version 1.4.5
  • PHP Error Log Viewer Version 2.1.0
  • Popular Brand SVG Icons - Simple Icons Version 2.4.
  • Shield Version 8.7.0
  • Switch to ClassicPress Version 1.1.0
  • WP Fastest Cache Version 0.9.0.4
  • WYSIWYG Advanced Version 0.1.0

ERROR LOGS:

(url edited for privacy)

[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'ID' of non-object in xxx/wp-includes/class-wp-query.php on line 3735
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_title' of non-object in xxx/wp-includes/class-wp-query.php on line 3737
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_name' of non-object in xxx/wp-includes/class-wp-query.php on line 3739
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_type' of non-object in xxx/wp-includes/class-wp-query.php on line 3870
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'ID' of non-object in xxx/wp-includes/class-wp-query.php on line 3735
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_title' of non-object in xxx/wp-includes/class-wp-query.php on line 3737
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_name' of non-object in xxx/wp-includes/class-wp-query.php on line 3739
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'ID' of non-object in xxx/wp-includes/class-wp-query.php on line 3735
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_title' of non-object in xxx/wp-includes/class-wp-query.php on line 3737
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_name' of non-object in xxx/wp-includes/class-wp-query.php on line 3739
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'ID' of non-object in xxx/wp-includes/class-wp-query.php on line 3735
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_title' of non-object in xxx/wp-includes/class-wp-query.php on line 3737
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_name' of non-object in xxx/wp-includes/class-wp-query.php on line 3739
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_type' of non-object in xxx/wp-includes/post-template.php on line 584
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_parent' of non-object in xxx/wp-includes/post-template.php on line 636

THIS ONE RELATES TO THE THEME
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_name' of non-object in xxx/wp-content/themes/twenty8teen/inc/filters.php on line 17

[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'ID' of non-object in xxx/wp-includes/class-wp-query.php on line 3735
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_title' of non-object in xxx/wp-includes/class-wp-query.php on line 3737
[15-Mar-2020 17:41:35 UTC] PHP Notice: Trying to get property 'post_name' of non-object in xxx/wp-includes/class-wp-query.php on line 3739

THIS ONE RELATES TO CLASSICSEO PLUGIN
[16-Mar-2020 01:10:53 UTC] PHP Notice: Trying to get property 'name' of non-object in xxx/wp-content/plugins/classicpress-seo/includes/replace-variables/class-base.php on line 60

(For context, the Classic SEO error got repeated several times at different timings - for “several” I mean that the list was way over 10 errors with the same text)

What I tried

Tried disabling plugins one by one, errors go away every time I disable a random plugin from the list. tried disabling all of them and re-enabling one by one waiting one day between each, errors do not show. Tried to install the health check plugin that allows from troubleshooting without affecting the front-end, for some reason it did not work properly, and as usual, the errors during testing went away.
At first, there were only generic ones related to the wp-query and the non-object. from today it shows also one log for the theme and many for ClassicSEO showing the same error on line 60

Steps to reproduce

install these plugins and theme on a ClassicPress site obtained by switching a WordPress install

Context

First of all, The first error to show were the ones about wp query, the plugin and theme one showed up uninvited today. The only thing that changed today is an update to PHP error log viewer.
The site seems working, but I want to understand why this happens to remove the cause. Before all this started my plugin list was longer I had some plugins by ClassicPress plugin devs that I removed in an attempt to understand if they were causing all that but nope. I also selected different plugins to handle the features I needed thinking those could be the issue but apparently even changing this after a while the error log shows again.

So now, I am sure there is a stupid silly thing I am not seeing. I could live with the notices being about something vague, but it is starting to affect plugins and the theme. and it is one of the plugins doing this I think. I tried also changing the theme… and with a default theme I get the notices all the same. Before destroying everything and making it in plain HTML without a line of CSS, do you happen to have a piece of advice?

Thanks for updating to the new version of PHP Error Log Viewer. It doesn’t query for posts or work in conjunction with post types, so, the error won’t be there. You probably made other changes and lost track of them…or, just didn’t realize they were changes. :wink: I also suspect it’s not the theme.

Following the code referenced at the lines in these error messages, you’re having an issue with the is_page() function. It is expecting a post object and it’s not getting one. Search your plugins and themes for is_page and then disable that plugin/theme. It’s my guess that, if you clear up those errors, the others will also disappear.

This one is a problem with the is_singular() function. Do the same as above to find it.

Now you know why it’s happening… but, you’ll still have to root out the particular cause. Have you deleted plugins directly from the server after deactivating them, or deleted records from the raw database? Those might be next steps to look at.

Since you asked, I’m going to recommend this (again)… find and follow some basic PHP tutorials to get your bearings. There are a million great, free tutorials. Without a basic understanding, you’re going to spend a ton of time on the tiniest of issues… and that leads one to feel like, what was it…oh, right: "destroying everything ". :wink:

PS. Destroying everything now and again can be a practical part of the learning process.

1 Like

I don’t think this advice will help you much. It’s obvious that all the code is failing because the “object” that is being used is not a real object that is expected (non-object). The code in the plugins and theme are valid code, but the messages are telling you that the data is unexpected. Something fundamental changed, which could be a hack on your database or a PHP update by your host (causing a plugin failure perhaps) .
Because the first error is in wp_query, that’s what you should figure out. The other errors are just cascading because of bad data from that.

It will tell you exactly which plugin or theme is the cause, or, if it’s not the cause.

I think both advices are correct. I will finish my shift and see where it all comes from
As x deleting plugin from ftp or cleansing database (mean culpa) I did both.
But not recently. And the issue was already there

1 Like

Not really. She already did this, and it’s a valid core function to call. I know from the theme at least, I made sure that the call was on a hook that was after the query was parsed, so I know it’s not a problem there.
If you have bad data, you will get all kinds of Notices. The trick is to find why there is bad data.

2 Likes

Uhm. Bada data.
This rings a bell. Being hacked is a common thing on Aruba…

Right. But, what is making that call? I doubt it’s your theme causing the issue. I also doubt she edited core files. So, I’m feeling sure it has to be a plugin or widget, or perhaps some personal-edits-gone-wrong somewhere along the way. I can’t think of any occasions where a PHP bump caused a post to not be retrieved, but, then again, I’ve only looked at the code in 2 of those plugins. I think a hack is unlikely

Agreed.

I agree with this generally. This looks to me like bad data is being injected into some global state, for example, something may be setting the global $post to an empty array. (That’s probably not what it actually is, but just to give an idea…)

If it is something like this, you won’t find offending calls to is_singular and is_page etc in a plugin or theme. These also happen as part of the core code, and this isn’t a problem in itself until they get bad data.

I’ve also never seen this particular issue before, so I don’t really know exactly what could have gone wrong.

Ok. So that explains why disabling plugins and mixing them is not giving satisfaction.
And why I may not find an hack.
For reference this site only has a bunch of pages. I am planning on adding posts later, but for now there are no posts. So it is running that code while loading the pages since they just are a post type. But it’s one place left. Will try to rebuild site elsewhere afresh and see if just putting it up like this express errors.
If it does, I will take it down to pieces, but I will find what it is.

Just to keep everyone updated, i discovered what the issue really was. Before all this happened I fidgeted with several plugins allowing to crosspost from/to Tumblr. These were very outdated plugins but reportedly still working, what I did was trying them live (and this is very wrong I know) and then, since for some reasons they were not working due to the Tumblr API changing like there’s no tomorrow and Tumblr posts formats and the like, I removed them. What I did not consider is these plugins were doing something I was not aware of to the way CP handles post types to make CP post types able to be posted in Tumblr as Tumblr post formats.
Fact is removing the plugin left somewhere in the code something that affected the whole site.
What sparked understanding is @Code_Potent remark about which plugins were calling the functions, and @joyously pointing me towards detecting bad code, but also the question about deleting plugins via ftp or messing with database.
Now the question I have is: How does CP is going to handle plugins leaving stuff behind them? This experience leads me to think that a plugin that leaves a reminder is no good to a site. I guess I should just open a thread for that…

There is no current way to handle them. Is up to developer to provide their plugins with a script that erases (or ask to) plugin data (custom post type, options, cronjobs, database tables, taxonomies, roles, stuff in htaccess…).

Every plugin has his own way to handle this: some (bad) leaves stuff around, Classic Commerce deletes data only if you set to true a constant (WC_REMOVE_ALL_DATA), Classic SEO does the same with a filter (cpseo_clear_data_on_uninstall) Stats for Update Manager deletes options and DB entries, Update Manager deletes CTP, Vars has an option to choose what to do, just as examples.

And CP don’t know who registered what.

2 Likes