[wp-trac] [WordPress Trac] #43561: $object_id parameter is string instead of integer in delete_{$meta_type}_meta inside delete_metadata_by_mid()

WordPress Trac noreply at wordpress.org
Thu Mar 28 21:55:56 UTC 2019


#43561: $object_id parameter is string instead of integer in
delete_{$meta_type}_meta inside delete_metadata_by_mid()
--------------------------------+--------------------------
 Reporter:  salcode             |       Owner:  johnbillion
     Type:  defect (bug)        |      Status:  accepted
 Priority:  normal              |   Milestone:  5.2
Component:  Options, Meta APIs  |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  has-patch           |     Focuses:
--------------------------------+--------------------------
Changes (by johnbillion):

 * owner:  (none) => johnbillion
 * status:  new => accepted


Comment:

 This change makes sense.

 The `delete_{$meta_type}_meta` action documents its `$object_id` parameter
 as an integer. Inside `delete_metadata()` it gets cast to an integer, but
 inside `delete_metadata_by_mid()` it doesn't, and remains a string. The
 same goes for the subsequent `deleted_{$meta_type}_meta` action.

 The only place the `$object_id` variable gets used in
 `delete_metadata_by_mid()` is in the call to `wp_cache_delete()`, in which
 case it's a benefit to ensure that the object key is also an integer so
 its type matches the key used in `delete_metadata()`.

 This means that casting `$object_id` to an integer inside
 `delete_metadata_by_mid()` is safe and correct.

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


More information about the wp-trac mailing list