[wp-trac] [WordPress Trac] #65269: Replace spl_object_hash() with spl_object_id() for improved performance in widget factory and plugin callback handling

WordPress Trac noreply at wordpress.org
Tue May 19 13:20:06 UTC 2026


#65269: Replace spl_object_hash() with spl_object_id() for improved performance in
widget factory and plugin callback handling
-------------------------+-----------------------------
 Reporter:  arshidkv12   |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch
  Focuses:               |
-------------------------+-----------------------------
 This patch replaces spl_object_hash() usage with spl_object_id() in
 WP_Widget_Factory and _wp_filter_build_unique_id().

 Changes:
 - wp-includes/class-wp-widget-factory.php
 - wp-includes/plugin.php

 Reason:
 spl_object_id() returns an integer identifier internally assigned to an
 object, which avoids generating a hash string and is faster and more
 memory efficient compared to spl_object_hash().

 This improves performance in:
 - widget registration/unregistration
 - plugin filter callback identity generation


 Compatibility notes:
 - spl_object_id() requires PHP 7.2+
 - WordPress's minimum supported PHP version should be verified before
 merging this change.
 - Functionality remains identical since both are used only for object
 identity mapping.

 Testing:
 - Widgets register/unregister correctly
 - Filters/actions behave identically
 - No regression in callback uniqueness

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65269>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list