Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

#64077 closed defect (bug) (maybelater)

Cache is_multisite() and is_network_admin() to reduce redundant calls

Reported by: mukesh27's profile mukesh27 Owned by: mukesh27's profile mukesh27
Milestone: Priority: normal
Severity: normal Version:
Component: Plugins Keywords: has-patch
Focuses: administration, performance Cc:

Description

The wp-admin/plugins.php file makes repeated calls to is_multisite() and is_network_admin() throughout the plugin management logic. This leads to redundant function calls that can add up on sites with many plugins.

Change History (2)

This ticket was mentioned in PR #10146 on WordPress/wordpress-develop by @mukesh27.


5 weeks ago
#1

  • Keywords has-patch added; needs-patch removed

Trac ticket: https://core.trac.wordpress.org/ticket/64077

This PR refactors the src/wp-admin/plugins.php file to improve efficiency and maintainability by caching the results of is_multisite() and is_network_admin() in local variables. All subsequent checks throughout the file now use these cached variables, reducing repeated function calls and improving readability. No functional behavior is changed.

Refactoring for efficiency and readability:

  • Cached is_multisite() and is_network_admin() results in $is_multisite and $is_network_admin variables at the top of the file, and replaced all repeated calls to these functions with the variables throughout the plugin management logic.
  • Updated all conditional checks and function calls that previously used is_multisite() and is_network_admin() to use the new local variables, including plugin activation, deactivation, automatic updates, and UI display logic.

#2 @mukesh27
5 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from assigned to closed

As discussed in PR we don't need these changes for now.

Note: See TracTickets for help on using tickets.