Make WordPress Core

Changeset 45064


Ignore:
Timestamp:
03/28/2019 09:58:45 PM (7 years ago)
Author:
johnbillion
Message:

Options, Meta APIs: Ensure the $object_id parameter passed to the delete_{$meta_type}_meta and deleted_{$meta_type}_meta filters is always an integer.

Props salcode

Fixes #43561

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/meta.php

    r45036 r45064  
    813813        // Fetch the meta and go on if it's found.
    814814        if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) {
    815                 $object_id = $meta->{$column};
     815                $object_id = (int) $meta->{$column};
    816816
    817817                /** This action is documented in wp-includes/meta.php */
  • trunk/tests/phpunit/tests/meta/deleteMetadata.php

    r42343 r45064  
    145145                $this->assertFalse( $p2_cache );
    146146        }
     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        }
    147164}
Note: See TracChangeset for help on using the changeset viewer.