From d35d467c9cb7057f532883c57066468b5d6f182f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 11 May 2023 11:43:21 +0000 Subject: [PATCH] Plugins: Remove `is_object()` check in `WP_Hook:build_preinitialized_hooks()`. This is a minor performance enhancement: * If an object is passed, the call to `is_object()` will be redundant. * If a non-object is passed, the `instanceof` operator (a variant of `is_a()`) will first [https://github.com/php/php-src/blob/f42992f/Zend/zend_builtin_functions.c#L630-L631 check if it is an object] before doing any further processing. Therefore, no additional processing cycles should be wasted in both cases. Follow-up to [38571]. Props bor0, johnbillion, davidbaumwald. Fixes #58290. Built from https://develop.svn.wordpress.org/trunk@55748 git-svn-id: http://core.svn.wordpress.org/trunk@55260 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-hook.php | 8 +++++--- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wp-includes/class-wp-hook.php b/wp-includes/class-wp-hook.php index 4796503dcc..0f7dc4b7a3 100644 --- a/wp-includes/class-wp-hook.php +++ b/wp-includes/class-wp-hook.php @@ -290,11 +290,13 @@ final class WP_Hook implements Iterator, ArrayAccess { $nesting_level = $this->nesting_level++; $this->iterations[ $nesting_level ] = array_keys( $this->callbacks ); - $num_args = count( $args ); + + $num_args = count( $args ); do { $this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] ); - $priority = $this->current_priority[ $nesting_level ]; + + $priority = $this->current_priority[ $nesting_level ]; foreach ( $this->callbacks[ $priority ] as $the_ ) { if ( ! $this->doing_action ) { @@ -410,7 +412,7 @@ final class WP_Hook implements Iterator, ArrayAccess { $normalized = array(); foreach ( $filters as $hook_name => $callback_groups ) { - if ( is_object( $callback_groups ) && $callback_groups instanceof WP_Hook ) { + if ( $callback_groups instanceof WP_Hook ) { $normalized[ $hook_name ] = $callback_groups; continue; } diff --git a/wp-includes/version.php b/wp-includes/version.php index ba566197bc..1ac68d28f8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55747'; +$wp_version = '6.3-alpha-55748'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.