veda-consulting-company / uk.co.vedaconsulting.mailchimp

Other
22 stars 43 forks source link

Extension interferes with menu items #356

Open agh1 opened 1 year ago

agh1 commented 1 year ago

The method of adding menu items can interfere with custom menu items added in the Navigation Menu page and nested under the Mailings menu.

To reproduce:

  1. Install the extension
  2. Visit the Navigation Menu admin page and create a new menu item with "Mailings" as the parent menu item.
  3. Note that it doesn't appear in the menu.
  4. Repeat 4-5 more times. Notice that eventually the menu items start to appear.
  5. Disable the extension and see how all of the custom menu items appear.
  6. Re-enable the extension and see several disappear.

It seems that the code here is the problem: https://github.com/veda-consulting-company/uk.co.vedaconsulting.mailchimp/blob/220f6571858276f9cca92d0ae4cd812468f6dcfb/mailchimp.php#L429-L433

By taking the max ID of the menu items as they were passed to the hook and assuming that nobody would be adding further menu items, certainly not in the Mailings menu, it ends up interfering with custom menu items and other extensions' menu items that appear under Mailings.

I'm not 100% confident of the solution, but I think it would be to add navigation items via the API and position them appropriately.

agh1 commented 1 year ago

If anyone needs a workaround, just create a pile of custom menu items under Mailings until they start to show up, then create the custom menu item you actually need, then delete the filler ones. This will leave a gap in the Navigation IDs big enough for those four Mailchimp items to be inserted with overlapping IDs.