Hello I had the following issue:
Notice: Undefined offset: 6 i tb_megamenu_insert_tb_item()
row 347
When i looked at row 346 i saw that $col_content variable could either have a value in it, or be an empty array = array();
and in 347 that array was used to query inside it, but it does not take into consideration that the value could be empty array, in that case we should not query at all.
so I put the code inside a condition that the variable cannot be empty. and the notice goes away.
so now it looks like this:
<?php
function tb_megamenu_insert_tb_item(&$item_config, $row, $col, $item) {
$i = 0;
$col_content = isset($item_config['rows_content'][$row][$col]['col_content']) ? $item_config['rows_content'][$row][$col]['col_content'] : array();
if(!$col_content) { //this statement is new
while ($i < count($col_content) && $col_content[$i]['weight'] < $item['link']['weight']) {
$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];
}
} //closing if statement
$item_config['rows_content'][$row][$col]['col_content'][$i] = array(
'mlid' => $item['link']['mlid'],
'type' => 'menu_item',
'weight' => $item['link']['weight'],
'tb_item_config' => array(),
);
}
?>I wonder if this could be added to the next release?
Thanks,
/K
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff-tb_megamenu-2482491-10-11.txt | 444 bytes | danepowell |
| #11 | tb_megamenu-2482491-11.patch | 1.75 KB | danepowell |
Comments
Comment #1
Anonymous (not verified) commentedComment #2
Anonymous (not verified) commentedComment #3
Anonymous (not verified) commentedThat change created new issues, so if none else is seeing this then it has to be my configuration, If i find something else i will bring it up.
Comment #4
Anonymous (not verified) commentedComment #5
sagar ramgade commentedHi,
We also faced the same issue, here is the solution in the form of patch file.
Comment #6
sagar ramgade commentedI still noticed that errors were getting logged in watchdog, so created a different patch.
Comment #7
broeker commentedRegarding the patch in #6 -- it only works if you have the module in sites/all:
--- a/sites/all/modules/tb_megamenu/tb_megamenu.functions.inc
+++ b/sites/all/modules/tb_megamenu/tb_megamenu.functions.inc
should be:
--- a/tb_megamenu/tb_megamenu.functions.inc
+++ b/tb_megamenu/tb_megamenu.functions.inc
Don't have time to reroll at the moment but will let you know if the patch works for us -- we are also seeing this error.
Comment #8
broeker commentedFYI when we applied this patch we were only seeing the last menu item for all top-level parent menu items, e.g.
My Menu
* Link One
* Link Two
* Link Three (Only this one shows)
With the patch reverted things go back to normal and all menu links show.
Comment #9
ki commentedFixed error of #6 reported in #8.
Comment #10
danepowell commented@Ki patches need to be made relative to the project root, not your Drupal root. See the patch guide: https://www.drupal.org/node/707484
This is the same code as #9 but formatted correctly.
Comment #11
danepowell commentedLooks like the whitespace cleanup in #10 conflicts with another patch, I'll remove it.
Comment #12
Alestaan commentedI applied the patch because i got the same error as kentoro and now, i got the following error:
"Notice : Undefined offset: 0 in tb_megamenu_sync_config() (line 329 in \tb_megamenu\tb_megamenu.functions.inc)."
Any thought ?
Comment #13
sittard commentedSame issue here after upgrading to PHP 5.6.16
Comment #14
maatthieu commentedHi I just got exactly the same error ("Notice : Undefined offset: 0 in tb_megamenu_sync_config() (line 329 in \tb_megamenu\tb_megamenu.functions.inc)."). Then I went to "structure>TB Mega Menu" to configure the menu ; I just change create a new column inside the seconde menu then saved it. And the notice disappeared.
Comment #15
tedfordgif commentedThe last patch also has an issue.
Comment #16
lanceh1412 commentedLooks like this issue is a duplicate of this one. I was getting the same problem. The solution in #3 of that issue seems to work for me. This error did actually take my site offline as suggested was possible in #10 of that issue. It was only by disabling the module that i was able to get the site up and running again.
Comment #17
nevergoneDuplicate: #2571547: Notice : Undefined offset: 5 dans tb_megamenu_insert_tb_item() (ligne 343 dans sites/all/modules/tb_megamenu/tb_megamenu.functions.inc).
Comment #18
nevergone