Hello,

I have a concern, but only for the first menu, the other menu work very well. The menu does not show me any links and I even messages that are 6 :
Notice : Undefined offset: 0 dans tb_megamenu_insert_tb_item() (ligne 343 dans /sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).
Notice : Undefined offset: 1 dans tb_megamenu_insert_tb_item() (ligne 343 dans /sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).
Notice : Undefined offset: 2 dans tb_megamenu_insert_tb_item() (ligne 343 dans /sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).
Notice : Undefined offset: 3 dans tb_megamenu_insert_tb_item() (ligne 343 dans /sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).
Notice : Undefined offset: 4 dans tb_megamenu_insert_tb_item() (ligne 343 dans /sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).
Notice : Undefined offset: 5 dans tb_megamenu_insert_tb_item() (ligne 343 dans /sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).

what to do to solve the problem?

Thanks

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

pedrocorse created an issue. See original summary.

pedrocorse’s picture

Issue summary: View changes
John Franklin’s picture

I had a similar issue and fixed it by going to the TB Mega Menu configuration page and resaving the menu. It looks like TBMM can't always handle changes made in the Drupal core menu admin UI.

shimmertron’s picture

I managed to fix the errors by deactivating(not uninstalling) the tb megamenu module, clearing cache and then reactivating the mode.
Edit: Actually comment #3 worked better.

Justin Langley’s picture

It appears during this section (tb_megamenu.functions.inc, line ~343):

  while ($i < count($col_content) && $col_content[$i]['weight'] < $item['link']['weight']) {
    $i++;
  }

It's possible that the keys for $col_content are not always in numerical order. I'm not sure where this is happening. Cleared the cache, rebuilt the menu router table, nothing solved this. So before I dug too much deeper, I tried writing this while function as a foreach like so:

  foreach($col_content as $menu_link) {
    if ($menu_link['weight'] < $item['link']['weight']) {
      $i++;
    }
  }

This appears to do the same thing, but agnostic of array keys.

jaydul’s picture

Getting Like this Error.

Notice: Undefined offset: 7 in tb_megamenu_insert_tb_item() (line 343 of /var/www/html/sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).

josh.fabean’s picture

I'm getting the same issue, any more awesome suggestions?

I tried previous suggests here none worked for me. What I ended up doing what commenting out line 347, going to the tb_megamenu configure page, re-saving the menu that was causing the issues. I then put back that line and everything worked.

Epoxyde’s picture

Solution in #7 worked for me, thanks.

cgeorge29’s picture

I am also having this problem. I tried solutions 3 and 7. However my menu started acting wonky, not showing all items, and only showing some. It took a lot of re-saves, turn on/off every menu item to get it to see all items again.

However never stopped throwing errors.

So I am slammed with:
Notice: Undefined offset: 0 in tb_megamenu_sync_config() (line 329 of /srv/bindings/586660de7acf4cc680e3f1a689cd882d/code/sites/all/modules/tb_megamenu/tb_megamenu.functions.inc)

and

Notice: Undefined offset: 0 in tb_megamenu_insert_tb_item() (line 343 of /srv/bindings/586660de7acf4cc680e3f1a689cd882d/code/sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).

Not sure what to do. This is new. The only environment change has been an update to PHP 5.5. However this change was done slowly and through three testing environments, and NONE of the other test brances threw these errors. Hope someone knows what to do to resolve this.

Thank you.

freelock’s picture

This issue is worse than it appears. The issue is that the tb_megamenu_insert_tb_item() function mangles the stored data in a way that eventually leads to this error -- and can even take your site offline.

I just had this happen on a client site. They had deleted a menu link, and rearranged some other links, and bam! Site offline message. With a string of errors similar to those reported above (but in English).

By extracting the json blob from tb_megamenus.menu_config in an unbroken dev copy of the site to the same value in the broken production database, I found two lines added under a col_content object: both of them null.

And the reason: col_content should not be an object, it should be an indexed array. But because it's encoded in JSON, as soon as this function starts assigning to indexes that don't exist, it's changed from an indexed array to an associative array, which gets exported as a JSON object. At that point you're screwed -- future inserts under this key will leave gaps in the sequence, and if you then insert something in the menu that is earlier than one of these gaps, you're going to have trouble.

For example:

Before update, JSON:

"1134": {
    "rows_content": [
      [
        {
          "col_content": {
            "1": {
              "mlid": "1135",
              "type": "menu_item",
              "weight": "-50",
              "tb_item_config": []
            },
            "2": {
              "mlid": "1140",
              "type": "menu_item",
              "weight": "-47",
              "tb_item_config": []
            },
            "7": {
              "mlid": "1145",
              "type": "menu_item",
              "weight": "-41",
              "tb_item_config": []
            },
            "8": {
              "mlid": "1149",
              "type": "menu_item",
              "weight": "-38",
              "tb_item_config": []
            },
            "9": {
              "mlid": "1150",
              "type": "menu_item",
              "weight": "-37",
              "tb_item_config": []
            },
            "10": {
              "mlid": "1151",
              "type": "menu_item",
              "weight": "-36",
              "tb_item_config": []
            },
            "11": {
              "mlid": "1152",
              "type": "menu_item",
              "weight": "-35",
              "tb_item_config": []
            }
          },
          "col_config": []
        }
      ]
    ],
    "submenu_config": {
      "width": "",
      "class": "",
      "group": "0"
    },
    "item_config": {
      "class": "",
      "xicon": "",
      "caption": "",
      "alignsub": "",
      "group": "0",
      "hidewcol": "0",
      "hidesub": "0"
    }
  },

After update:

  "1134": {
    "rows_content": [
      [
        {
          "col_content": {
            "2": {
              "mlid": "1135",
              "type": "menu_item",
              "weight": "-49",
              "tb_item_config": []
            },
            "3": {
              "mlid": "1150",
              "type": "menu_item",
              "weight": "-40",
              "tb_item_config": []
            },
            "4": {
              "mlid": "1152",
              "type": "menu_item",
              "weight": "-38",
              "tb_item_config": []
            },
            "5": null,
            "6": null,
            "8": {
              "mlid": "1140",
              "type": "menu_item",
              "weight": "-46",
              "tb_item_config": []
            },
            "9": {
              "mlid": "1145",
              "type": "menu_item",
              "weight": "-44",
              "tb_item_config": []
            },
            "10": {
              "mlid": "1146",
              "type": "menu_item",
              "weight": "-43",
              "tb_item_config": []
            },
            "11": {
              "mlid": "1149",
              "type": "menu_item",
              "weight": "-41",
              "tb_item_config": []
            }
          },
          "col_config": []
        }
      ]
    ],
    "submenu_config": {
      "width": "",
      "class": "",
      "group": "0"
    },
    "item_config": {
      "class": "",
      "xicon": "",
      "caption": "",
      "alignsub": "",
      "group": "0",
      "hidewcol": "0",
      "hidesub": "0"
    }
  },

What I think this should look like:

  "1134": {
    "rows_content": [
      [
        {
          "col_content": [
            {
              "mlid": "1135",
              "type": "menu_item",
              "weight": "-49",
              "tb_item_config": []
            },
            {
              "mlid": "1150",
              "type": "menu_item",
              "weight": "-40",
              "tb_item_config": []
            },
            {
              "mlid": "1152",
              "type": "menu_item",
              "weight": "-38",
              "tb_item_config": []
            },
            {
              "mlid": "1140",
              "type": "menu_item",
              "weight": "-46",
              "tb_item_config": []
            },
            {
              "mlid": "1145",
              "type": "menu_item",
              "weight": "-44",
              "tb_item_config": []
            },
            {
              "mlid": "1146",
              "type": "menu_item",
              "weight": "-43",
              "tb_item_config": []
            },
            {
              "mlid": "1149",
              "type": "menu_item",
              "weight": "-41",
              "tb_item_config": []
            }
          ],
          "col_config": []
        }
      ]
    ],
    "submenu_config": {
      "width": "",
      "class": "",
      "group": "0"
    },
    "item_config": {
      "class": "",
      "xicon": "",
      "caption": "",
      "alignsub": "",
      "group": "0",
      "hidewcol": "0",
      "hidesub": "0"
    }
  },

... will work on a patch soon.

freelock’s picture

P.S. Commenting out line 347 would lead to data loss -- the link getting inserted would replace the one at its same position.

And in our case we couldn't even open up the configure page without getting an error.

The brute-force fix for this is to rewrite this as an indexed array inside this function. Might well be a much more elegant array_split method, though iterating/rewriting should clean up any data that isn't yet lost but already saved as an associative array.

John Franklin’s picture

Any chance of a patch in the next day or so? I have a client with this module and would like to avoid a frantic call.

freelock’s picture

FileSize
1.68 KB

Attached patch is still untested, but it should correct any bad data currently in the database by converting any associative arrays into indexed arrays at this level, and do the right thing going forward. It will not recover data already lost.

freelock’s picture

Status: Active » Needs review

Updating status...

capfive’s picture

Priority: Major » Critical
Status: Needs review » Reviewed & tested by the community

Ran into this issue, thankfully it was only a dev site!

Great find there Freelock, I OWE YOU A BEER!

That was a scary 21 minutes.... thanks again!

AgentJay’s picture

I tried this patch and it fixed the errors that were being reported, but it broke some of the sub menus. Some would have links missing, other would be fine.

I tried to create a new menu after applying the patch and all the sub-menus would only show the first link.

After I reverted the patch everything is working again, but I'm back to offset errors in the log.

duntuk’s picture

Tried the #13 patch... and yup it needs to include ALL the children, not just the first menu items-- as noted in #16.

duntuk’s picture

FileSize
37.14 KB
15.44 KB

Also... one major issue with TB_megamenu module is the database table structure it uses for the "tb_megamenus" table.

It uses totally NON-unique data as PRIMARY (which needs to be unique if it's PRIMARY):

menu_name
language

If you have a multilingual and/or "Domain Access" site that share the same menus, this structure will be invalid, because you're going to have either/or the SAME language and/or same menu name in these PRIMARY columns.

tb_megagemenus table structure

What needs to be done, is the database structure should have an additional column (INT, auto increment ) that can be set as PRIMARY--which will eliminate the duplicate data...

Example of duplicate data in tb_megamenus PRIMARY columns:

tb_megamenu showing duplicate content

freelock’s picture

Hi,

Yes, it looks like we had a typo in the original patch, we hit this problem too. We've fixed this, will post a fixed patch next week when I'm back at the code...

@duntuk the database itself won't let you insert non-unique values into a primary key. In this case, the primary key is across the menu_name and language columns, which means the combination of those fields is what needs to be unique. There's no issue with the data structure there. (If there's an issue with the code retrieving the right row, that's a code issue, not a data structure issue).

freelock’s picture

Status: Reviewed & tested by the community » Needs work

Setting back to Needs Work as the patch is incorrect...

freelock’s picture

Status: Needs work » Needs review
FileSize
1.66 KB

Updated patch, which corrects the previous issue that led to missing menu items...

freelock’s picture

Status: Needs review » Needs work

Hmm. We're still seeing the first row getting its column width unset. New patch coming soon.

freelock’s picture

Status: Needs work » Needs review
FileSize
2.13 KB

Yet another new roll of the patch.

This time it corrects a slightly different, but related issue -- it turns out that in certain circumstances, the first column loses its configuration, and gets reset to 12 grids wide. This is because of some (still) messed up logic in tb_megamenu_sync_config() -- this patch basically prevents it from clobbering config that does actually exist.

duntuk’s picture

Thanks @freelock for your patch in #23. Applying majority of it to the drupal 8 version (which is no longer available here) of this module fixed the following error:

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 227 of /public_html/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

Applied it up to the following in "TBMegaMenuBuilder.php":

$new_config = array(
     'mlid' => $item['link']['mlid'],
     'type' => 'menu_item',
     'weight' => $item['link']['weight'],
     'tb_item_config' => array(),
   );

So the entire file looks like this:


/**
 * @file 
 * Contains \Drupal\tb_megamenu\TBMegaMenuBuilder.
 * 
 * Retrieve menus and Mega Menus.
 */

namespace Drupal\tb_megamenu;

use Drupal\Core\Menu\MenuTreeParameters;

class TBMegaMenuBuilder {

  /**
   * Get the configuration of blocks.
   * @param string $menu_name
   * @param string $theme
   * @return array
   */
  public static function getBlockConfig($menu_name, $theme) {
    $menu = self::getMenus($menu_name, $theme);
    return isset($menu->block_config) ? json_decode($menu->block_config, true) : array();
  }

  /**
   * Get menus that belongs TB mega menu.
   * 
   * @global stdClass $language
   * @param string $menu_name
   * @param string $theme
   * @return array
   */
  public static function getMenus($menu_name, $theme) {
    $query = \Drupal::service('database')->select('menu_tree', 'm');
    $query->leftJoin('tb_megamenus', 't', 't.menu_name = m.menu_name');
    return $query->fields('t', array('menu_config', 'block_config'))
            ->condition('t.theme', $theme)
            ->condition('m.menu_name', $menu_name)
            ->execute()
            ->fetchObject();
  }

  public static function getMenuItem($menu_name, $plugin_id) {
    $tree = \Drupal::menuTree()->load($menu_name, (new MenuTreeParameters())->onlyEnabledLinks());
    //  Need to review this.
    //  if (function_exists('i18n_menu_localize_tree')) {
    //    $tree = i18n_menu_localize_tree($tree);
    //  }
    $item = self::findMenuItem($tree, $plugin_id);
    return $item;
  }

  /**
   * search by menu item.
   * 
   * @param type $tree
   * @param type $plugin_id
   * @return type
   */
  public static function findMenuItem($tree, $plugin_id) {
    foreach ($tree as $menu_plugin_id => $item) {
      if ($menu_plugin_id == $plugin_id) {
        return $item;
      }
      elseif ($result = self::findMenuItem($item->subtree, $plugin_id)) {
        return $result;
      }
    }
    return NULL;
  }

  /**
   * Load blocks by block_id.
   * 
   * @param string $block_id
   * @return array
   */
  public static function loadEntityBlock($block_id) {
    return \Drupal::entityManager()->getStorage('block')->load($block_id);
  }

  /**
   * Get configuration of menu.
   * 
   * @param string $menu_name
   * @param string $theme
   * @return stdClass
   */
  public static function getMenuConfig($menu_name, $theme) {
    $menu = self::getMenus($menu_name, $theme);
    return isset($menu->menu_config) ? json_decode($menu->menu_config, TRUE) : array();
  }

  /**
   * Create the default attributes for the configuration of block.
   * 
   * @param array $block_config
   */
  public static function editBlockConfig(&$block_config) {
    $block_config += array(
      'animation' => 'none',
      'style' => '',
      'auto-arrow' => TRUE,
      'duration' => 400,
      'delay' => 200,
      'always-show-submenu' => TRUE,
      'off-canvas' => 0,
      'number-columns' => 0
    );
  }

  /**
   * Set the default values to configuration in Sub TB Megamenu if it's empty.
   * 
   * @param type $submenu_config
   */
  public static function editSubMenuConfig(&$submenu_config) {
    $submenu_config += array(
      'width' => '',
      'class' => '',
      'group' => '',
    );
  }

  /**
   * Set the default values to configuration in TB Megamenu item if it's empty.
   * 
   * @param array $item_config
   */
  public static function editItemConfig(&$item_config) {
    $attributes = array(
      'xicon' => '',
      'class' => '',
      'caption' => '',
      'alignsub' => '',
      'group' => 0,
      'hidewcol' => 0,
      'hidesub' => 0
    );
    foreach ($attributes as $attribute => $value) {
      if (!isset($item_config[$attribute])) {
        $item_config[$attribute] = $value;
      }
    }
  }

  /**
   * Set the default values to configuration in columns if it's empty.
   * 
   * @param array $col_config
   */
  public static function editColumnConfig(&$col_config) {
    $attributes = array(
      'width' => 12,
      'class' => '',
      'hidewcol' => 0,
      'showblocktitle' => 0,
    );
    foreach ($attributes as $attribute => $value) {
      if (!isset($col_config[$attribute])) {
        $col_config[$attribute] = $value;
      }
    }
  }

  /**
   * Create block which using tb_megamenu.
   * 
   * @param string $menu_name
   * @param string $theme
   * @return array
   */
  public static function renderBlock($menu_name, $theme) {
    return array(
      '#theme' => 'tb_megamenu',
      '#menu_name' => $menu_name,
      '#block_theme' => $theme,
      '#section' => 'backend',
      '#post_render' => array('tb_megamenu_attach_number_columns')
    );
  }

  /**
   * Get Id of column.
   *
   * @param int $number_columns
   * @return string
   */
  public static function getIdColumn($number_columns) {
    $value = &drupal_static('column');
    if (!isset($value)) {
      $value = 1;
    }
    elseif (!$number_columns || $value < $number_columns) {
      $value++;
    }
    return "tb-megamenu-column-$value";
  }

  /**
   * Get all of blocks in system without blocks which belong to TB Mega Menu.
   * In array, each element includes key which is plugin_id and value which is label of block. 
   * 
   * @staticvar array $_blocks_array
   * @return array
   */
  public static function getAllBlocks() {
    static $_blocks_array = array();
    if (empty($_blocks_array)) {
      // Get default theme for user.
      $theme_default = \Drupal::config('system.theme')->get('default');
      // Get storage handler of block.
      $block_storage = \Drupal::entityManager()->getStorage('block');
      // Get the enabled block in the default theme.
      $entity_ids = $block_storage->getQuery()->condition('theme', $theme_default)->execute();
      $entities = $block_storage->loadMultiple($entity_ids);
      $_blocks_array = [];
      foreach ($entities as $block_id => $block) {
        if ($block->get('settings')['provider'] != 'tb_megamenu') {
          $_blocks_array[$block_id] = $block->label();
        }
      }
      asort($_blocks_array);
    }
    return $_blocks_array;
  }

  /**
   * Create options for animation.
   * 
   * @param array $block_config
   * @return array
   */
  public static function createAnimationOptions($block_config) {
    return array(
      'none' => t('None'),
      'fading' => t('Fading'),
      'slide' => t('Slide'),
      'zoom' => t('Zoom'),
      'elastic' => t('Elastic')
    );
  }

  /**
   * Create options for styles.
   * 
   * @param array $block_config
   * @return array
   */
  public static function createStyleOptions($block_config) {
    return array(
      '' => t('Default'),
      'black' => t('Black'),
      'blue' => t('Blue'),
      'green' => t('Green'),
    );
  }

  public static function buildPageTrail($menu_items) {
    $trail = array();
    foreach ($menu_items as $pluginId => $item) {
      $is_front = \Drupal::service('path.matcher')->isFrontPage();
      $route_name = $item->link->getPluginDefinition()['route_name'];
      if ($item->inActiveTrail || ($route_name == '<front>' && $is_front)) {
        $trail[$pluginId] = $item;
      }

      if ($item->subtree) {
        $trail += self::buildPageTrail($item->subtree);
      }
    }
    return $trail;
  }

  /**
   * 
   * @param array $menu_items
   * @param array $menu_config
   * @param string $section
   */
  public static function syncConfigAll($menu_items, &$menu_config, $section) {
    foreach ($menu_items as $id => $menu_item) {
      $item_config = isset($menu_config[$id]) ? $menu_config[$id] : array();
      if ($menu_item->hasChildren || $item_config) {
        self::syncConfig($menu_item->subtree, $item_config, $section);
        $menu_config[$id] = $item_config;
        self::syncConfigAll($menu_item->subtree, $menu_config, $section);
      }
    }
  }

  /**
   * 
   * @param array $items
   * @param array $item_config
   * @param string $section
   */
  public static function syncConfig($items, &$item_config, $section) {
    if (empty($item_config['rows_content'])) {
      $item_config['rows_content'][0][0] = array(
        'col_content' => array(),
        'col_config' => array()
      );

      foreach ($items as $plugin_id => $item) {
        if ($item->link->isEnabled()) {
          $item_config['rows_content'][0][0]['col_content'][] = array(
            'type' => 'menu_item',
            'plugin_id' => $plugin_id,
            'tb_item_config' => array(),
            'weight' => $item->link->getWeight(),
          );
        }
      }
      if (empty($item_config['rows_content'][0][0]['col_content'])) {
        unset($item_config['rows_content'][0]);
      }
    }
    else {
      $hash = array();
      foreach ($item_config['rows_content'] as $i => $row) {
        foreach ($row as $j => $col) {
          foreach ($col['col_content'] as $k => $tb_item) {
            if ($tb_item['type'] == 'menu_item') {
              $hash[$tb_item['plugin_id']] = array(
                'row' => $i,
                'col' => $j
              );
              $existed = false;
              foreach ($items as $plugin_id => $item) {
                if ($item->link->isEnabled() && $tb_item['plugin_id'] == $plugin_id) {
                  $item_config['rows_content'][$i][$j]['col_content'][$k]['weight'] = $item->link->getWeight();
                  $existed = true;
                  break;
                }
              }
              if (!$existed) {
                unset($item_config['rows_content'][$i][$j]['col_content'][$k]);
                if (empty($item_config['rows_content'][$i][$j]['col_content'])) {
                  unset($item_config['rows_content'][$i][$j]);
                }
                if (empty($item_config['rows_content'][$i])) {
                  unset($item_config['rows_content'][$i]);
                }
              }
            }
            else if (!self::IsBlockContentEmpty($tb_item['block_id'], $section)) {
              unset($item_config['rows_content'][$i][$j]['col_content'][$k]);
              if (empty($item_config['rows_content'][$i][$j]['col_content'])) {
                unset($item_config['rows_content'][$i][$j]);
              }
              if (empty($item_config['rows_content'][$i])) {
                unset($item_config['rows_content'][$i]);
              }
            }
          }
        }
      }
      $row = -1;
      $col = -1;
      foreach ($items as $plugin_id => $item) {
        if ($item->link->isEnabled()) {
          if (isset($hash[$plugin_id])) {
            $row = $hash[$plugin_id]['row'];
            $col = $hash[$plugin_id]['col'];
            continue;
          }
          if ($row > -1) {
            self::InsertTBMenuItem($item_config, $row, $col, $item);
          }
          else {
            $row = $col = 0;
            while (isset($item_config['rows_content'][$row][$col]['col_content'][0]['type']) &&
            $item_config['rows_content'][$row][$col]['col_content'][0]['type'] == 'block') {

              $row++;
            }
            self::InsertTBMenuItem($item_config, $row, $col, $item);
            if (!isset($item_config['rows_content'][$row][$col]['col_config'])) {
           $item_config['rows_content'][$row][$col]['col_config'] = array();
           }
          }
        }
      }
    }
  }

  /**
   * Sync order of menu items between menu and tb_megamenus.
   * 
   * @param array $menu_config
   */
  public static function syncOrderMenus(&$menu_config) {
    foreach ($menu_config as $mlid => $config) {
      foreach ($config['rows_content'] as $rows_id => $row) {
        $item_sorted = array();
        // Get weight from items.
        foreach ($row as $col) {
          $num_order = 0;
          foreach ($col['col_content'] as $menu_item) {
            if ($menu_item['type'] == 'menu_item') {
              if (isset($item_sorted[$menu_item['weight']])) {
                // Can't have floats as array key
                $item_sorted[(string) ($menu_item['weight'] + sprintf('.%04d', $num_order))] = $menu_item;
                $num_order++;
              } else {
                $item_sorted[$menu_item['weight']] = $menu_item;
              }
            }
          }
        }

        ksort($item_sorted, SORT_NUMERIC); // Sort menu by weight.megamenu

        foreach ($row as $rid => $col) {
          foreach ($col['col_content'] as $menu_item_id => $menu_item) {
            if ($menu_item['type'] == 'menu_item') {
              $menu_config[$mlid]['rows_content'][$rows_id][$rid]['col_content'][$menu_item_id] = array_shift($item_sorted);
            }
          }
        }
      }
    }
  }

  /**
   * 
   * @param type $block_id
   * @param type $section
   * @return boolean
   */
  public static function IsBlockContentEmpty($block_id, $section) {
    $entity_block = self::loadEntityBlock($block_id);
    if ($entity_block && ($entity_block->getPlugin()->build() || $section == 'backend')) {
      return TRUE;
    }
    return FALSE;
  }

  /**
   * 
   * @param array $item_config
   * @param string $row
   * @param string $col
   * @param type $item
   */
  public static function InsertTBMenuItem(&$item_config, $row, $col, $item) {
    // $i = 0;
	$added = FALSE;
	$new_col = array();
    $col_content = isset($item_config['rows_content'][$row][$col]['col_content']) ? $item_config['rows_content'][$row][$col]['col_content'] : array();
   // while ($i < count($col_content) && $col_content[$i]['weight'] < $item->link->getWeight()) {
   //    $i++;
   //  }
   //  for ($j = count($col_content); $j > $i; $j--) {
   //    $item_config['rows_content'][$row][$col]['col_content'][$j] = $item_config['rows_content'][$row][$col]['col_content'][$j - 1];
   //  }
    // $item_config['rows_content'][$row][$col]['col_content'][$i] = array(
	// If this tree has not been corrected due to issue #2571547, $col_content might be an associative array.
	// It should be an indexed array. Build a new indexed array, discarding the keys.
	$new_config = array(
      'plugin_id' => $item->link->getPluginId(),
      'type' => 'menu_item',
      'weight' => $item->link->getWeight(),
      'tb_item_config' => array(),
    );
	
  }

}

millionleaves’s picture

#23 worked for me - thanks. I'd been experiencing the error for a long time and ignoring it until I encountered the issue described in #10. #23 did the trick.

petebox’s picture

I had a similar issue and fixed it by going to the TB Mega Menu configuration page and resaving the menu. It looks like TBMM can't always handle changes made in the Drupal core menu admin UI.

Method described in #3 worked for me perfectly. I also just resaved my menu at configuration page and the errors were gone. Thanks everyone.

drupal_simply_amazing’s picture

#23 worked also for me. thanks @freelock

frodeste’s picture

Can anyone commit the patch? It seems to be fix the issue.