[wp-trac] [WordPress Trac] #17694: DRY: code to display update counts is redundant and buggy
WordPress Trac
wp-trac at lists.automattic.com
Sun Jun 5 20:31:37 UTC 2011
#17694: DRY: code to display update counts is redundant and buggy
-----------------------------+-----------------------------
Reporter: mitchoyoshitaka | Owner: mitchoyoshitaka
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 3.2
Severity: normal | Keywords: has-patch
-----------------------------+-----------------------------
Approximately the exact same code exists in three places for collecting
information on available updates and formatting a UI string for it:
wp_admin_bar_updates_menu(), wp-admin/menu.php, and in wp-
admin/network/menu.php.
Let's not repeat ourselves.
In addition, the hacky cut-and-paste nature of these three instances of
code actually cause weird edge case bugs. This patch also fixes some other
minor issues:
- in wp-admin/menu.php, if is_multisite() and !is_super_admin() but
!empty( $menu_perms['plugins'] ), the $plugin_update_count variable will
be undefined.
- in wp-admin/network/menu.php, if !current_user_can( 'update_themes' )
but current_user_can( 'update_core' ), the variable $theme_update_count
referenced in the sum for $update_count will not be defined. A similar
issue could occur with $plugin_update_count.
- in wp-admin/network/menu.php, if current_user_can( 'update_themes' ), we
print a useless <span class='update-plugins count-0'><span class='theme-
count'>0</span></span>. We actually have CSS to then hide this stuff
(#adminmenu li span.count-0, #sidemenu li a .count-0). It just shouldn't
be printed.
- in wp-admin/network/menu.php, if !current_user_can( 'update_core' ), the
total update count of themes and plugins is not printed in the Updates
label.
- wp_admin_bar_updates_menu() would only add the ab-updates menu if
!current_user_can('install_plugins') instead of checking 'update_plugins'
and not checking 'update_themes' or 'update_core' at all.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17694>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list