diff --git src/wp-includes/meta.php src/wp-includes/meta.php
index 010822fdc8..3f311bdb14 100644
|
|
function delete_metadata_by_mid( $meta_type, $meta_id ) { |
748 | 748 | |
749 | 749 | // Fetch the meta and go on if it's found. |
750 | 750 | if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) { |
751 | | $object_id = $meta->{$column}; |
| 751 | $object_id = (int) $meta->{$column}; |
752 | 752 | |
753 | 753 | /** This action is documented in wp-includes/meta.php */ |
754 | 754 | do_action( "delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value ); |
diff --git tests/phpunit/tests/meta/deleteMetadata.php tests/phpunit/tests/meta/deleteMetadata.php
index 5527d1f02f..3b75aacdb5 100644
|
|
class Tests_Meta_DeleteMetadata extends WP_UnitTestCase { |
144 | 144 | $p2_cache = wp_cache_get( $p2, 'post_meta' ); |
145 | 145 | $this->assertFalse( $p2_cache ); |
146 | 146 | } |
| 147 | |
| 148 | /** |
| 149 | * @ticket 43561 |
| 150 | */ |
| 151 | public function test_object_id_is_int_inside_delete_post_meta() { |
| 152 | $post_id = self::factory()->post->create(); |
| 153 | $meta_id = add_metadata( 'post', $post_id, 'my_key', 'my_value' ); |
| 154 | add_action( 'delete_post_meta', [ $this, 'action_check_object_id_is_int' ], 10, 2 ); |
| 155 | delete_metadata_by_mid( 'post', $meta_id ); |
| 156 | } |
| 157 | |
| 158 | public function action_check_object_id_is_int( $meta_type, $object_id ) { |
| 159 | $this->assertEquals( |
| 160 | 'integer', |
| 161 | gettype( $object_id ) |
| 162 | ); |
| 163 | } |
147 | 164 | } |