• Resolved Ov3rfly

    (@ov3rfly)


    Getting PHP Fatal error after plugin update 2.4.1 to 2.5.1 on WP 4.9.20/21 websites.

    Rolling back to No Nonsense 2.4.1 via FTP fixes the error.

    Seems the new added flush_rewrite_rules() in r34nono_install() causes the issue:

    [31-Aug-2022 07:13:07 UTC] PHP Fatal error:  Uncaught Error: Call to a member function flush_rules() on null in /home/example/htdocs/wp-includes/rewrite.php:273
    Stack trace:
    #0 /home/example/htdocs/wp-content/plugins/no-nonsense/no-nonsense.php(62): flush_rewrite_rules()
    #1 /home/example/htdocs/wp-content/plugins/no-nonsense/no-nonsense.php(52): r34nono_install()
    #2 /home/example/htdocs/wp-includes/class-wp-hook.php(286): r34nono_plugins_loaded('')
    #3 /home/example/htdocs/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #4 /home/example/htdocs/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #5 /home/example/htdocs/wp-settings.php(327): do_action('plugins_loaded')
    #6 /home/example/htdocs/wp-config.php(104): require_once('/home/example...')
    #7 /home/example/htdocs/wp-load.php(37): require_once('/home/example...')
    #8 /home/example/htdocs/wp-admin/admin.php(31): require_once('/home/example...')
    #9 /home/ in /home/example/htdocs/wp-includes/rewrite.php on line 273
Viewing 10 replies - 1 through 10 (of 10 total)
  • This is strange. I have the plugin running on several sites myself and have not had this issue. Also the flush_rewrite_rules() call isn’t new; I just consolidated two separate functions that were both running on the same hook.

    I’ll investigate further, but have you verified that this is not a plugin/theme conflict with your specific setup?

    Ah… I missed initially that you are running WordPress 4.9. All of my client sites are on 6.0, and I haven’t been specifically testing this with earlier versions.

    Is there a particular reason you’ve held back on that version? It’s possible that’s the issue.

    That said… the “requires” version for No Nonsense is officially 4.9, so I do need to find a way to resolve this issue.

    And that said, I checked the documentation for flush_rewrite_rules() and there are examples (going back 7 years) of using the function with register_activation_hook(), so this error shouldn’t be happening in 4.9 unless you’ve modified the core code or if there’s a plugin/theme conflict.

    Let me know about my previous question (whether or not you’ve checked for a plugin/theme conflict), and also whether or not you’ve modified any of the WordPress core, and in the meantime I’ll set up a test install of WP 4.9 and see if I can replicate the issue.

    OK, I set up a clean install of WordPress 4.9.21, installed No Nonsense, and it is working properly.

    No Nonsense test in WordPress 4.9 screenshot

    Whatever the issue is appears to be specific to your configuration… most likely a plugin or theme conflict as noted earlier.

    Thread Starter Ov3rfly

    (@ov3rfly)

    Seems you did not follow the description “after plugin update 2.4.1 to 2.5.1”:

    • Install fresh WP 4.9.21
    • Install No Nonsense 2.4.1
    • Change some setting (as example Remove WP emoji) and save (this maybe not required)
    • Update to No Nonsense 2.5.1
    • Error: Call to a member function flush_rules() on null in /example/wp-includes/rewrite.php on line 273

    OK… I installed No Nonsense 2.4.1 and ran the update and I am also getting the fatal error. Investigating…

    Please try the upgrade to 2.5.1.1. It resolves the issue for me on my WP 4.9 test site.

    I’ve removed the flush_rewrite_rules() call from the r34nono_install() function and added it directly to a separate register_activation_hook() call, which is how it was configured prior to version 2.5.

    Thread Starter Ov3rfly

    (@ov3rfly)

    Plugin update 2.4.1 to 2.5.1.1 works, no PHP error.

    Thanks for quick investigation and fix.

    But after update I get this message “Thank you for installing No Nonsense. To get started, please visit the Settings page.” even though the plugin was installed and configured before already.

    That’s an intentional new feature… but yes it would be better to have it run only on install, not update. I’m working on that.

    Version 2.5.2 is out now. I’ve refactored the install/update logic into two separate functions, so now that admin notice will only display on plugin activation, not when running an update.

    Thread Starter Ov3rfly

    (@ov3rfly)

    Everything works as expected now.

    Thanks again for quick investigation and fix.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘PHP Fatal error after update’ is closed to new replies.