Notice: Trying to access array offset on value of type bool in responsive_menu_tree_output()

Created on 27 March 2023, over 1 year ago
Updated 17 September 2023, over 1 year ago

Dear maintainers,

Thank you for this awesome module! Recently I'm having the current notice message:

Notice: Trying to access array offset on value of type bool in responsive_menu_tree_output() (line 107 of /../public_html/sites/all/modules/responsive_menu/includes/responsive_menu.menu.inc).

What can this be?
Miguel

🐛 Bug report
Status

RTBC

Version

3.7

Component

Code

Created by

🇵🇹Portugal miguelbraga

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @miguelbraga
  • 🇵🇹Portugal miguelbraga

    Im proposing this fix, if it makes any sense, I'm not a developer:

        if (
            isset($data['link']['href'], $router_item['tab_root_href'], $_GET['q']) &&  // Check if the variables are set
            is_array($data['link']['href']) &&                                          // Check if $data['link']['href'] is an array
            is_array($router_item['tab_root_href']) &&                                  // Check if $router_item['tab_root_href'] is an array
            is_array($_GET['q']) &&                                                     // Check if $_GET['q'] is an array
            $data['link']['href'] == $router_item['tab_root_href'] &&                    // Perform the comparison
            $data['link']['href'] != $_GET['q']
        ) {
            $data['link']['localized_options']['attributes']['class'][] = 'active';
        }
    
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India dineshkumarbollu

    Hi miguelbraga
    I am providing patch for this issue in D7, added isset() checks to ensure the existence of the required keys and used is_array() and is_string() functions to validate the data types,which helps to prevent the "array offset on value of type bool" error.

  • Status changed to RTBC over 1 year ago
  • 🇮🇳India shubham_jain

    @dineshkumarbollu, I review that this implies and moving it to the RTBC.

Production build 0.71.5 2024