wpsharks / comet-cache

An advanced WordPress® caching plugin inspired by simplicity.
https://cometcache.com
GNU General Public License v3.0
76 stars 17 forks source link

PHP Fatal error: Uncaught Error: Call to a member function get_year_permastruct() on null in wp-includes/link-template.php:453 #880

Open raamdev opened 7 years ago

raamdev commented 7 years ago

We have at least two independent reports of an error that only appears occasionally and only when Comet Cache is active. Some reports indicate that a "blank screen is shown" and the cache must be cleared before things start working again.

PHP Fatal error: Uncaught Error: Call to a member function get_year_permastruct() on null in /home/wp-includes/link-template.php:453
Stack trace:
#0 /home/wp-content/plugins/comet-cache/src/includes/traits/Plugin/WcpDateArchiveUtils.php(72): get_year_link(‘2017’)
#1 /home/wp-content/plugins/comet-cache/src/includes/traits/Plugin/WcpPostUtils.php(103): WebSharks\CometCache\Classes\Plugin->autoClearDateArchiveCache(1221, false)
#2 /home/wp-includes/class-wp-hook.php(300): WebSharks\CometCache\Classes\Plugin->autoClearPostCache(1221)
#3 /home/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(”, Array)
#4 /home/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#5 /home/wp-includes/post.php(5714): do_action(‘clean_post_cach…’, 1221, Object(WP_Post))
#6 /home/wp-includes/post.php(3402): clean_po in /home/wp-includes/link-template.php on line 453

The error is referring to a failure at /home/wp-includes/link-template.php on line 453, which is a call to get_year_permastruct() (a WordPress Core function). In this case, the error says that the error is a “Call to a member function get_year_permastruct() on null”… what’s null? According to the error, $wp_rewrite, which was just defined as global earlier in that function, is null, which doesn’t make sense.

So it sounds like something (perhaps another plugin or some other custom code) is messing with the WordPress globals and/or changing the $wp_rewrite global in some unexpected way. I also wouldn't rule out a WordPress Core bug somewhere.

We have several reports of this issue now, so I'm opening this GitHub issue so that we can start collecting relevant data and attempt to reproduce the problem.

emmaport commented 6 years ago

The best solution, which I have tried, is to uninstall the wordpress and reinstall manually. Installing wordpress using sofwares like 1Click Install, Fantastico Deluxe, Softaculous etc., leads to this error. A fine tutorial on manual installation of Wordpress can be found here: https://www.youtube.com/watch?v=LIhNlzLgF78