WordPress.org

Make WordPress Core

Opened 13 months ago

Closed 8 months ago

Last modified 8 months ago

#23767 closed enhancement (wontfix)

remove_menu_page: Check for existing menu items

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

Description

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 13 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 SergeyBiryukov13 months ago

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

Looks like there are only two 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: http://codex.wordpress.org/Function_Reference/remove_menu_page.
  2. Manually unset the $menu global at some point.

Both are developer errors, so the developer should see the warning.

comment:2 sergej.mueller13 months ago

Any foreach command should be checked "if empty".

comment:3 SergeyBiryukov13 months 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.

comment:4 c3mdigital8 months ago

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

We shouldn't accommodate for developer errors.

comment:5 SergeyBiryukov8 months ago

  • Milestone Awaiting Review deleted
  • Resolution changed from worksforme to wontfix
Note: See TracTickets for help on using tickets.