Title: Array offset null
Last modified: March 13, 2023

---

# Array offset null

 *  [Jennifer Dust](https://wordpress.org/support/users/jldust/)
 * (@jldust)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/array-offset-null/)
 * 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 4**4
 *     ```wp-block-code
       //Suggest adding initial variable validation
       if ( $wp_nav_plus_limit_offset_options === null ){
       	return $items;
       }
       ```
   
 * **menu_segment.php – line 43**
 *     ```wp-block-code
       //Suggest adding initial variable validation
       if ( $wp_nav_plus_menu_segment_options === null ){
       	return $items;
       }
       ```
   
 * **start_depth.php – line 54**
 *     ```wp-block-code
       //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](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16556229)
 * 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](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16559174)
 * 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](https://wordpress.org/support/users/jldust/)
 * (@jldust)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16572658)
 * 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-block-code
       wp_nav_menu(
         array(
           'menu' => $sidebar_menu,
           'fallback_cb' => false,
           'container' => false,
           'start_depth' => 1,
           'depth' => 2
         )
       );
       ```
   
 *  Plugin Author [Matt Keys](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16572701)
 * 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?
 *  [tastymouse](https://wordpress.org/support/users/tastymouse/)
 * (@tastymouse)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16870501)
 * 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 2 years, 11 months ago by [tastymouse](https://wordpress.org/support/users/tastymouse/).
 *  Plugin Author [Matt Keys](https://wordpress.org/support/users/mattkeys/)
 * (@mattkeys)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16873071)
 * Hey [@tastymouse](https://wordpress.org/support/users/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!
 *  [tastymouse](https://wordpress.org/support/users/tastymouse/)
 * (@tastymouse)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16873930)
 * Hi [@mattkeys](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/wp-nav-plus/assets/icon-256x256.jpg?rev=1724550)
 * [WP Nav Plus](https://wordpress.org/plugins/wp-nav-plus/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-nav-plus/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-nav-plus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-nav-plus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-nav-plus/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [tastymouse](https://wordpress.org/support/users/tastymouse/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/array-offset-null/#post-16873930)
 * Status: not resolved