[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 15 20:13:00 UTC 2018


#43561: $object_id parameter is string instead of integer in
delete_{$meta_type}_meta inside delete_metadata_by_mid()
--------------------------+-----------------------------
 Reporter:  salcode       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 In `wp-includes/meta.php` inside the function `delete_metadata_by_mid()`
 the hook `do_action( "delete_{$meta_type}_meta" )` is called.

 While not documented here, earlier in the same same file this hook also
 appears and is documented as

 {{{
  * @param null|bool $delete     Whether to allow metadata deletion of the
 given type.
  * @param int       $object_id  Object ID.
  * @param string    $meta_key   Meta key.
  * @param mixed     $meta_value Meta value. Must be serializable if non-
 scalar.
  * @param bool      $delete_all Whether to delete the matching metadata
 entries
  *                              for all objects, ignoring the specified
 $object_id.
  *                              Default false.
 }}}


 however when the hook is called inside `delete_metadata_by_mid()` the
 `$object_id` is passed as a `string` not an `int`.

 It looks like this happens inside `delete_metadata_by_mid()` because
 `$object_id` is defined in these lines

 {{{
 if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) {
         $object_id = $meta->{$column};
 }}}

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


More information about the wp-trac mailing list