Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 3 years ago

#23767 closed enhancement (wontfix)

remove_menu_page: Check for existing menu items

Reported by: sergejmueller's profile sergej.mueller Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Warnings/Notices Keywords: has-patch
Focuses: Cc:


This error appears in my error log:

PHP Warning: Invalid argument supplied for foreach() in /www/htdocs/wp-admin/includes/plugin.php on line 1290

The if-empty patch is attached.

Attachments (1)

plugin.php.patch (375 bytes) - added by sergej.mueller 11 years ago.

Download all attachments as: .zip

Change History (9)

#1 @SergeyBiryukov
11 years ago

  • Keywords close added
  • Type changed from feature request to enhancement
  • Version changed from trunk to 3.5

Looks like there are only three ways to get this warning:

  1. Call remove_menu_page() after the admin is fully loaded, but before $menu global is set up, e.g. by hooking into auth_redirect action instead of admin_menu, which goes against the Codex example:
  2. Call remove_menu_page() on the admin_init hook instead of admin_menu. As noted in #19937, admin_init fires in some situations where there is no UI for which a menu will be built.
  3. Manually unset the $menu global at some point.

These are all developer errors, so the developer should see the warning.

Last edited 3 years ago by SergeyBiryukov (previous) (diff)

#2 @sergej.mueller
11 years ago

Any foreach command should be checked "if empty".

#3 @SergeyBiryukov
11 years ago

Similar enhancements were suggested in #17299 and #18927.

The consensus was that we shouldn't hide warnings generated by plugin or theme bugs. That would only make debugging harder.

#4 @c3mdigital
11 years ago

  • Keywords close removed
  • Resolution set to worksforme
  • Status changed from new to closed

We shouldn't accommodate for developer errors.

#5 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution changed from worksforme to wontfix

#7 @SergeyBiryukov
3 years ago

#43714 was marked as a duplicate.

#8 @SergeyBiryukov
3 years ago

#42538 was marked as a duplicate.

#9 @SergeyBiryukov
3 years ago

#51254 was marked as a duplicate.

Note: See TracTickets for help on using tickets.