[wp-trac] [WordPress Trac] #12718: Better structure for admin menu

WordPress Trac wp-trac at lists.automattic.com
Thu Jul 26 18:21:49 UTC 2012


#12718: Better structure for admin menu
------------------------------------+-----------------------
 Reporter:  scribu                  |       Owner:
     Type:  enhancement             |      Status:  reopened
 Priority:  normal                  |   Milestone:  3.5
Component:  Plugins                 |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |
------------------------------------+-----------------------

Comment (by nacin):

 After talking with ryan a bit on this, and doing some research, I'd like
 to bring up some backwards compatibility concerns, and possible solutions.

 The most obvious way to be backwards compatible is to make both $menu and
 $submenu instances of ArrayObject, and watch any changes to them. This,
 however, is fraught with issues because ArrayObjects are not real arrays,
 and thus cannot go through array_* functions in PHP without issuing
 E_WARNINGS.

 But, if we're going to end up breaking only few plugins —  and the worst
 that happens is something they hacked in isn't quite what they wanted it
 to be, and the issue is a warning rather than a fatal error, then I can be
 okay with sticking to an ArrayObject watcher.

 Even then, we found a number of very interesting hacks against the $menu
 global that could be caught with ArrayObject — iterating through it, then
 setting/unsetting things — but that class is going to be a doozy. I guess
 that's where I come in? :-)

 Let's say we don't move on this until 3.6. I kind of want to drop-in a
 change to make $menu and $submenu simple ArrayObjects that mirror real
 array functionality of iteration and access, and then see what kind of bug
 reports we get during a beta period, before reverting back to standard
 arrays for 3.5. That could clean up quite a bit of custom code now.

 So, attached are five different search results of the plugins directory:
 looking for `global $menu` (330 results), `global $submenu` (400 results),
 `$GLOBALS['menu']` (20), `$GLOBALS['submenu']` (20), and
 `custom_menu_order` (20). At some point, we should go through all of these
 — yes, all — and make an inventory of what kind of modifications people
 are making. If they are only doing things covered by ArrayIterator and
 ArrayAccess, great. If they are using array_* functions, then we need to
 make a note.

 Ryan has also searched WP.com (which includes the VIP repo), and hasn't
 found too many bad situations, but nonetheless, there is plenty of code
 that a new API here could affect.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12718#comment:55>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list