Make WordPress Core


Ignore:
Timestamp:
03/28/2019 09:58:45 PM (5 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.