[wp-trac] [WordPress Trac] #58458: Move the load of `array_keys` to a different level in the `WP_Hook` class

WordPress Trac noreply at wordpress.org
Mon Sep 18 12:39:34 UTC 2023


#58458: Move the load of `array_keys` to a different level in the `WP_Hook` class
---------------------------------------------+---------------------------
 Reporter:  bor0                             |       Owner:  spacedmonkey
     Type:  enhancement                      |      Status:  closed
 Priority:  normal                           |   Milestone:  6.4
Component:  Plugins                          |     Version:  6.3
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  performance
---------------------------------------------+---------------------------
Changes (by spacedmonkey):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56609" 56609]:
 {{{
 #!CommitTicketReference repository="" revision="56609"
 Plugins: Store result of call to array_keys, to save repeated calls in
 WP_Hook class.

 In the `WP_Hook` class the function `array_keys` was called every time an
 array of hook priorities was needed. For sites with lots of filters or
 actions, this would result in thousands of calls to the `array_keys`
 function, which uses server resources. Instead of recomputing this array
 every time it is needed, only compute it when filters are added and
 removed, then store the result as a class property. Improve unit tests to
 ensure this behaviour is tested.

 Props spacedmonkey, bor0, flixos90, hellofromTonya, mukesh27.
 Fixes #58458.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58458#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list