diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php index 2f272f4cdd..3397ef11ae 100644 --- a/src/wp-includes/meta.php +++ b/src/wp-includes/meta.php @@ -137,8 +137,9 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v if ( !$meta_type || !$meta_key ) return false; - if ( !$object_id = absint($object_id) ) + if ( ! is_numeric( $object_id ) || ! $object_id = absint( $object_id ) ) { return false; + } if ( ! $table = _get_meta_table($meta_type) ) return false; diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index 976ef53da7..f9484ed388 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -627,4 +627,18 @@ class Tests_User extends WP_UnitTestCase { // If this test fails, it will error out for calling the to_array() method on a non-object. $this->assertInstanceOf( 'WP_Error', wp_update_user( array( 'ID' => $user_id ) ) ); } + + /** + * @ticket 28315 + */ + function test_user_meta_error() { + $this->factory->user->create( array( 'user_email' => 'taco@burrito.com' ) ); + $id = $this->factory->user->create( array( 'user_email' => 'taco@burrito.com' ) ); + + $this->assertWPError( $id ); + @update_user_meta( $id, 'key', 'value' ); + + $metas = array_keys( get_user_meta( 1 ) ); + $this->assertNotContains( 'key', $metas ); + } }