mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-01 15:00:15 +00:00
REST API: Move object type-specific metadata integrations from the wrapper functions to the low-level Meta API functions.
Object type-specific actions that should happen before or after modification of metadata have so far been part of the respective wrapper functions. By using action and filter hooks, this changeset ensures they are always executed, even when calling the lower-level Meta API functions directly, which the REST API does as a prime example. Merges [43729] to trunk. Props flixos90, spacedmonkey. Fixes #44467. git-svn-id: https://develop.svn.wordpress.org/trunk@43982 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -224,4 +224,41 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
|
||||
$num_queries++;
|
||||
$this->assertSame( $num_queries, $wpdb->num_queries );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44467
|
||||
*/
|
||||
public function test_add_metadata_sets_comments_last_changed() {
|
||||
$comment_id = self::factory()->comment->create();
|
||||
|
||||
wp_cache_delete( 'last_changed', 'comment' );
|
||||
|
||||
$this->assertInternalType( 'integer', add_metadata( 'comment', $comment_id, 'foo', 'bar' ) );
|
||||
$this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44467
|
||||
*/
|
||||
public function test_update_metadata_sets_comments_last_changed() {
|
||||
$comment_id = self::factory()->comment->create();
|
||||
|
||||
wp_cache_delete( 'last_changed', 'comment' );
|
||||
|
||||
$this->assertInternalType( 'integer', update_metadata( 'comment', $comment_id, 'foo', 'bar' ) );
|
||||
$this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44467
|
||||
*/
|
||||
public function test_delete_metadata_sets_comments_last_changed() {
|
||||
$comment_id = self::factory()->comment->create();
|
||||
|
||||
update_metadata( 'comment', $comment_id, 'foo', 'bar' );
|
||||
wp_cache_delete( 'last_changed', 'comment' );
|
||||
|
||||
$this->assertTrue( delete_metadata( 'comment', $comment_id, 'foo' ) );
|
||||
$this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user