Make WordPress Core


Ignore:
Timestamp:
10/15/2018 11:45:16 AM (6 years ago)
Author:
flixos90
Message:

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.

Props flixos90, spacedmonkey.
Fixes #44467.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/tests/phpunit/tests/comment/metaCache.php

    r37954 r43729  
    211211        $this->assertSame( $num_queries, $wpdb->num_queries );
    212212    }
     213
     214    /**
     215     * @ticket 44467
     216     */
     217    public function test_add_metadata_sets_comments_last_changed() {
     218        $comment_id = self::factory()->comment->create();
     219
     220        wp_cache_delete( 'last_changed', 'comment' );
     221
     222        $this->assertInternalType( 'integer', add_metadata( 'comment', $comment_id, 'foo', 'bar' ) );
     223        $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
     224    }
     225
     226    /**
     227     * @ticket 44467
     228     */
     229    public function test_update_metadata_sets_comments_last_changed() {
     230        $comment_id = self::factory()->comment->create();
     231
     232        wp_cache_delete( 'last_changed', 'comment' );
     233
     234        $this->assertInternalType( 'integer', update_metadata( 'comment', $comment_id, 'foo', 'bar' ) );
     235        $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
     236    }
     237
     238    /**
     239     * @ticket 44467
     240     */
     241    public function test_delete_metadata_sets_comments_last_changed() {
     242        $comment_id = self::factory()->comment->create();
     243
     244        update_metadata( 'comment', $comment_id, 'foo', 'bar' );
     245        wp_cache_delete( 'last_changed', 'comment' );
     246
     247        $this->assertTrue( delete_metadata( 'comment', $comment_id, 'foo' ) );
     248        $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
     249    }
    213250}
Note: See TracChangeset for help on using the changeset viewer.