• Resolved snosites

    (@turkeybucket)


    I’m getting this fatal error on the main admin page for this plugin when using PHP 8.0:

    [21-May-2022 12:03:15 UTC] PHP Warning: Undefined array key “exclude_search” in /home/westdela/public_html/wp-content/plugins/ultimate-category-excluder/ultimate-category-excluder.php on line 81
    [21-May-2022 12:03:15 UTC] PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /home/westdela/public_html/wp-content/plugins/ultimate-category-excluder/ultimate-category-excluder.php:81

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    Thanks for the report. I’m not seeing these errors though. I’ve tried excluding some categories and having no categories selected. I also deactivated and reactivated the plugin.

    I don’t get the warning or the fatal error.

    I’m using PHP 8.0.13 and WP 5.9.3.

    Thread Starter snosites

    (@turkeybucket)

    I’m using PHP 8.0.14 and WP 5.9.3

    Here’s the full stack trace:
    [21-May-2022 16:51:32 UTC] PHP Warning: Undefined array key “exclude_search” in /home/westdela/public_html/wp-content/plugins/ultimate-category-excluder/ultimate-category-excluder.php on line 81
    [21-May-2022 16:51:32 UTC] PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /home/westdela/public_html/wp-content/plugins/ultimate-category-excluder/ultimate-category-excluder.php:81
    Stack trace:
    #0 /home/westdela/public_html/wp-content/plugins/ultimate-category-excluder/ultimate-category-excluder.php(81): in_array(‘-23’, NULL)
    #1 /home/westdela/public_html/wp-includes/class-wp-hook.php(307): ksuce_options_page(”)
    #2 /home/westdela/public_html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(”, Array)
    #3 /home/westdela/public_html/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
    #4 /home/westdela/public_html/wp-admin/admin.php(259): do_action(‘settings_page_u…’)
    #5 /home/westdela/public_html/wp-admin/options-general.php(10): require_once(‘/home/westdela/…’)
    #6 {main}
    thrown in /home/westdela/public_html/wp-content/plugins/ultimate-category-excluder/ultimate-category-excluder.php on line 81

    Here’s what this site has stored in the ksuceExcludes option in the wp_options table:
    a:3:{s:12:”exclude_main”;a:0:{}s:12:”exclude_feed”;a:1:{i:0;s:2:”-1″;}s:16:”exclude_archives”;a:0:{}}

    It looks like this site doesn’t have the “exclude_search” array stored, and so when the plugin is looping through the categories and checking to see if the cat ID is in the exclude_search array, it throws the error because there is no exclude_search array and PHP 8.0 throws a fatal error if in_array is used on null.

    Before making the in_array comparison, the plugin should check that $options[‘exclude_search’] is an array to prevent the fatal error.

    Or you could edit ksuce_get_options function to check that each of the four nested arrays in this option is set. If one of them isn’t, the array could be set at this point, and that would remove the error from line 81.

    Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    Should be fixed now!

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

The topic ‘Fatal error on admin page with PHP 8.0’ is closed to new replies.