• It appears with the recent update to WordPress core 6.1 (running PHP8.1) there seems to be a few error/warning notifications around validating for null offsets. I’ve identified these issues down to 3 specific files, and the same if statement within them, I would suggest adding a null validation prior to the check to resolve the issues. Here are the files and the lines I would add the validations before.

    limit_offset.php – line 44

    //Suggest adding initial variable validation
    if ( $wp_nav_plus_limit_offset_options === null ){
    	return $items;
    }

    menu_segment.php – line 43

    //Suggest adding initial variable validation
    if ( $wp_nav_plus_menu_segment_options === null ){
    	return $items;
    }

    start_depth.php – line 54

    //Suggest adding initial variable validation
    if ( $wp_nav_plus_start_depth_options === null ){
    	return $items;
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Matt Keys

    (@mattkeys)

    Hey Jennifer,

    Fun to see this plugin still has some life out there, it never really took off but I’m still proud of it 🙂

    At first read I thought you were reporting a PHP 8 related error, but I think you are actually talking about something else. That the check for a value on some of the plugin menu arguments isn’t handling values like -1, -2 correctly.

    Am I following you correctly? I have to admit I am actually a bit rusty on this plugin nowadays. It has been 6 years since writing it and 4 years since I’ve had to do any meaningful updates to it. But it sounds like you are probably describing a bug that has existed since day one.

    Plugin Author Matt Keys

    (@mattkeys)

    re-reading this with fresh eyes today. I’m not able to reproduce what you are seeing. Can you provide some example code of how your menu is using the parameters from this plugin, and the errors you are seeing?

    Thanks!

    Thread Starter Jennifer Dust

    (@jldust)

    Hi Matt,

    Thanks for taking a look at this, here is an example of the code we are using that we experienced the error message with.

    wp_nav_menu(
      array(
        'menu' => $sidebar_menu,
        'fallback_cb' => false,
        'container' => false,
        'start_depth' => 1,
        'depth' => 2
      )
    );
    Plugin Author Matt Keys

    (@mattkeys)

    Thanks for sharing that. It looks like a very typical use of this plugin. In my test environment that works as expected and doesn’t produce any errors. Testing with PHP 8.1.1 and WordPress 6.1.1. Using ACF Pro 6.0.7.

    Can you share the exact error text that you are seeing?

    I use the menu with the widget and get errors:

    Warning: Trying to access array offset on value of type null in /wp-content/plugins/wp-nav-plus/feature_classes/menu_segment.php on line 43

    Warning: Trying to access array offset on value of type null in /wp-content/plugins/wp-nav-plus/feature_classes/start_depth.php on line 54

    Warning: Trying to access array offset on value of type null in /wp-content/plugins/wp-nav-plus/feature_classes/limit_offset.php on line 44

    On another website on the same server and the same theme I don’t get any errors.

    • This reply was modified 1 year, 5 months ago by tastymouse.
    Plugin Author Matt Keys

    (@mattkeys)

    Hey @tastymouse,

    I’m having trouble reproducing those errors. Can you try resaving the widget settings to see if that makes any difference?

    These arrays should be getting set on the ‘wp_nav_menu_args’ action in the wp_nav_menu function. So I am not sure what would cause them to be NULL in your environment. Perhaps some other plugin/code is also making changes to the ‘wp_nav_menu_args’ filter and unsetting/rewriting those arguments.

    It would be worth checking out any other plugins/code meant to effect the menu on the site having this issue. If you are able to temporarily disable any related code and retest you might see these warnings go away.

    Let me know what you find!

    Hi @mattkeys ,

    You’re right. The problem is caused by Astra Pro plugin, it has a Nav Menu module and when I disable it the errors disappear.
    I don’t need the module on this site, so I just leave it disabled.

    Thanks, Tom

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Array offset null’ is closed to new replies.