Changeset 62408
- Timestamp:
- 05/22/2026 06:59:15 AM (2 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
-
src/wp-includes/class-wp-hook.php (modified) (1 diff)
-
src/wp-includes/class-wp-widget-factory.php (modified) (2 diffs)
-
src/wp-includes/plugin.php (modified) (2 diffs)
-
tests/phpunit/tests/hooks/buildUniqueId.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-hook.php
r61457 r62408 86 86 87 87 $idx = _wp_filter_build_unique_id( $hook_name, $callback, $priority ); 88 if ( null === $idx ) { 89 return; 90 } 88 91 89 92 $priority_existed = isset( $this->callbacks[ $priority ] ); -
trunk/src/wp-includes/class-wp-widget-factory.php
r54133 r62408 58 58 public function register( $widget ) { 59 59 if ( $widget instanceof WP_Widget ) { 60 $this->widgets[ spl_object_ hash( $widget ) ] = $widget;60 $this->widgets[ spl_object_id( $widget ) ] = $widget; 61 61 } else { 62 62 $this->widgets[ $widget ] = new $widget(); … … 75 75 public function unregister( $widget ) { 76 76 if ( $widget instanceof WP_Widget ) { 77 unset( $this->widgets[ spl_object_ hash( $widget ) ] );77 unset( $this->widgets[ spl_object_id( $widget ) ] ); 78 78 } else { 79 79 unset( $this->widgets[ $widget ] ); -
trunk/src/wp-includes/plugin.php
r62397 r62408 987 987 * @since 5.3.0 Removed workarounds for spl_object_hash(). 988 988 * `$hook_name` and `$priority` are no longer used, 989 * and the function always returns a string. 989 * and no longer returns false, but can still return void for invalid callbacks. 990 * @since 6.9.0 Returns explicit null if an invalid callback is supplied. 991 * @since 7.1.0 Uses spl_object_id() instead of spl_object_hash() for performance. 990 992 * 991 993 * @access private 992 994 * 993 * @param string $hook_name Unused. The name of the filter to build ID for. 994 * @param callable|string|array $callback The callback to generate ID for. The callback may 995 * or may not exist. 996 * @param int $priority Unused. The order in which the functions 997 * associated with a particular action are executed. 998 * @return string|null Unique function ID for usage as array key. 999 * Null if a valid `$callback` is not passed. 1000 */ 1001 function _wp_filter_build_unique_id( $hook_name, $callback, $priority ) { 995 * @param string $hook_name Unused. The name of the filter to build ID for. 996 * @param callable $callback The callback to generate ID for. The callback may 997 * or may not exist. 998 * @param int $priority Unused. The order in which the functions 999 * associated with a particular action are executed. 1000 * @return string|null Unique function ID for usage as array key, or null if it couldn't be determined. 1001 */ 1002 function _wp_filter_build_unique_id( $hook_name, $callback, $priority ): ?string { 1002 1003 if ( is_string( $callback ) ) { 1003 1004 return $callback; … … 1005 1006 1006 1007 if ( is_object( $callback ) ) { 1007 // Closures are currently implemented as objects. 1008 $callback = array( $callback, '' ); 1009 } else { 1010 $callback = (array) $callback; 1008 return (string) spl_object_id( (object) $callback ); 1009 } 1010 1011 $callback = (array) $callback; 1012 if ( ! isset( $callback[1] ) || ! is_string( $callback[1] ) ) { 1013 return null; 1011 1014 } 1012 1015 1013 1016 if ( is_object( $callback[0] ) ) { 1014 1017 // Object class calling. 1015 return spl_object_hash( $callback[0]) . $callback[1];1018 return ( (string) spl_object_id( $callback[0] ) ) . $callback[1]; 1016 1019 } elseif ( is_string( $callback[0] ) ) { 1017 1020 // Static calling.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)