Mega Menu is Unusable In 2.2.7/2.2.8: SanitizeMegaMenuLayout() Drops Item_id On Save, Wiping All Assigned Items And Flooding Builder + Front End With "Undefined Property: StdClass::$item_id" Warnings - Question | JoomShaper

Mega Menu is Unusable In 2.2.7/2.2.8: SanitizeMegaMenuLayout() Drops Item_id On Save, Wiping All Assigned Items And Flooding Builder + Front End With "Undefined Property: StdClass::$item_id" Warnings

Goran

Goran

Helix Framework 6 days ago

Steps to reproduce

  1. Edit a menu item, enable Mega Menu in the builder, add a row and insert menu items and/or modules into cells via the builder popover.
  2. Save the mega menu settings.
  3. Reopen the builder, or load any front-end page.

Actual result

  • Every assigned cell is persisted as {"type":"menu","id":"0"} / {"type":"module","id":"0","moduleId":"0"} - all assignments are silently lost.
  • The admin builder floods with PHP warnings (one per cell; for module cells one per installed module, because getTitle() loops all modules):
Warning: Undefined property: stdClass::$item_id in
src\Platform\Builders\MegaMenuBuilder.php on line 179 (module) / 189 (menu)
  • The front end floods with the same warnings from src\Core\Classes\HelixultimateMenu.php lines 507 and 516, and the rendered mega menu is empty.

Isolated reproduction of the data loss (PHP, against the shipped code) Input = exactly what assets/js/admin/megamenu.js (handleAddNewCell) sends:

$layout = [[ 'type' => 'row', 'attr' => [[ 'type' => 'column', 'colGrid' => '6', 'items' => [
    ['type' => 'menu_item', 'item_id' => '2933'],
    ['type' => 'module',    'item_id' => '311'],
]]]]];

// HelixUltimate\Framework\Platform\Helper::sanitizeMegaMenuLayout($layout) returns:
// [{"type":"row","attr":[{"type":"column","colGrid":"6","menuParentId":"0","moduleId":"0",
//   "items":[{"type":"menu","id":"0"},{"type":"module","id":"0","moduleId":"0"}]}]}]

Root cause Save pipeline Response::saveMegaMenuSettings() → Helper::sanitizeMegaMenuSettings() → Helper::sanitizeMegaMenuLayout() (Helper.php, ~line 1380):

$type = ($cell['type'] ?? '') === 'module' ? 'module' : 'menu';   // 'menu_item' coerced to 'menu'
$cleanCell = [
    'type' => $type,
    'id'   => (string) (int) ($cell['id'] ?? 0),                  // JS sends 'item_id', not 'id' -> always "0"
];

The builder JS sends {type: 'menu_item'|'module', item_id: <id>}; the sanitizer keeps neither the type nor the id. Both consumers then read the missing item_id unguarded: MegaMenuBuilder::getTitle() (lines 179/189, admin) and HelixultimateMenu::mega() (lines 507/516, front).

Expected result Saving the mega menu preserves assigned items; no PHP warnings.

Suggested fix in my humble oppinion:

$type = ($cell['type'] ?? '') === 'module' ? 'module' : 'menu_item';
$cleanCell = [
    'type'    => $type,
    'item_id' => (string) (int) ($cell['item_id'] ?? $cell['id'] ?? 0),
];
if ($type === 'module')
{
    $cleanCell['moduleId'] = (string) (int) ($cell['moduleId'] ?? $cell['item_id'] ?? 0);
}

Plus $item->item_id ?? 0 guards in MegaMenuBuilder::getTitle() and HelixultimateMenu::mega() so already-broken layouts stop emitting warnings.

Thank you and hope for quick fix on this.

2
4 Answers
Ziaul Kabir
Ziaul Kabir
Accepted Answer
Support Agent 6 days ago #228037

Hello Goran,

Thank you for the detailed report and for taking the time to investigate the root cause. I apologize for the inconvenience this issue has caused.

We were able to reproduce the issue on our end. As a temporary workaround, you can use the approach you suggested if it works in your environment.

We have identified the underlying issue and are working on a permanent fix, which will be included in the next release.

We appreciate your thorough analysis and the proposed solution. Thank you again for reporting this and for your patience while we address it.

Best Regards,

0
I
Iliyan
Accepted Answer
5 days ago #228302

Hello,

I think I am experiencing the same issue.

After configuring the Mega Menu and clicking Save, the configuration is not preserved. When I open the Mega Menu editor again, all the settings are gone.

I have tested with:

a completely new Joomla menu; a brand new Mega Menu; different browsers; disabled browser cache.

Regular Joomla menu items work correctly. The issue occurs only with the Helix Ultimate Mega Menu.

I have attached a screenshot of the Mega Menu before saving.

Joomla: 6.1.2 Helix Ultimate: 2.2.8 PHP: 8.3.x

Is this the same bug discussed in this topic, or is it a different issue?!

1
Ziaul Kabir
Ziaul Kabir
Accepted Answer
Support Agent 4 days ago #228348

Yes, this is the same issue.

For now, please disable the mega menu, click Save, and then enable it again. This should resolve the issue temporarily.

A permanent fix will be included in the next upcoming update.

Thanks!

0
S-D CONSULTING
S-D CONSULTING
Accepted Answer
3 hours ago #228853

Hi, we're having the exact same problem on all the websites where we use the megamenu.

We urgently need a workaround to find a suitable solution, because our menus are disappearing.

0