KTS915 / Test-ClassicPress-Directory

GNU General Public License v3.0
0 stars 0 forks source link

PHP Fatal error: Uncaught Error: Call to a member function get_queried_object_id() on null in /wp-includes/query.php:60 #1

Closed KTS915 closed 2 years ago

KTS915 commented 2 years ago

I fixed the issue on the author archives, so that now you can see the plugins, themes, and snippets of that particular author. At least, it's working fine on my localhost install. But it's produced a WSOD on the test site you can see and the logs have this explanation:

PHP Fatal error: Uncaught Error: Call to a member function get_queried_object_id() on null in /home/webbyboo/test-directory.webby-books.com/wp-includes/query.php:60

Stack trace:

0 /wp-content/mu-plugins/author.php(7): get_queried_object_id()

1 /wp-settings.php(254): include_once('/home/webbyboo/...')

2 /wp-config.php(112): require_once('/home/webbyboo/...')

3 /wp-load.php(37): require_once('/home/webbyboo/...')

4 /wp-blog-header.php(13): require_once('/home/webbyboo/...')

5 /index.php(17): require('/home/webbyboo/...')

6 {main}

thrown in /wp-includes/query.php on line 60

I don't really understand how get_queried_object_id() could ever be null anyway. I have tried checking to see if it's null before doing anything with it but, as you can see, the error is generated on line 7, and that is simply $author_id = get_queried_object_id(); which is obviously before I attempt to make use of it.

joyously commented 2 years ago

The author.php is in a mu plugin? Those get loaded before other plugins, and definitely before the theme, so it could be something to do with executing before the query is parsed. But I don't see how it would have worked before (although it was showing wrong results).

KTS915 commented 2 years ago

No, it's in the theme. And it worked before (while showing the wrong results) precisely because I didn't specify that the CPTs had to be by get_queried_object_id() because I wrongly assumed that that was implicit on the author archive. As I say, it's working fine on my localhost install, so I'm baffled.

joyously commented 2 years ago

As Simone said on Slack, it's not on this repo.

KTS915 commented 2 years ago

It most certainly is. Under themes -> classicpress-directory

KTS915 commented 2 years ago

Turned out to be a rogue file in the wrong place. Thanks, @joyously and Simone!