Make WordPress Core


Ignore:
Timestamp:
12/12/2018 03:02:00 AM (6 years ago)
Author:
jeremyfelt
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.

Merges [43729] to trunk.

Props flixos90, spacedmonkey.
Fixes #44467.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tests/phpunit/tests/comment/metaCache.php

    r42343 r43982  
    225225        $this->assertSame( $num_queries, $wpdb->num_queries );
    226226    }
     227
     228    /**
     229     * @ticket 44467
     230     */
     231    public function test_add_metadata_sets_comments_last_changed() {
     232        $comment_id = self::factory()->comment->create();
     233
     234        wp_cache_delete( 'last_changed', 'comment' );
     235
     236        $this->assertInternalType( 'integer', add_metadata( 'comment', $comment_id, 'foo', 'bar' ) );
     237        $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
     238    }
     239
     240    /**
     241     * @ticket 44467
     242     */
     243    public function test_update_metadata_sets_comments_last_changed() {
     244        $comment_id = self::factory()->comment->create();
     245
     246        wp_cache_delete( 'last_changed', 'comment' );
     247
     248        $this->assertInternalType( 'integer', update_metadata( 'comment', $comment_id, 'foo', 'bar' ) );
     249        $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
     250    }
     251
     252    /**
     253     * @ticket 44467
     254     */
     255    public function test_delete_metadata_sets_comments_last_changed() {
     256        $comment_id = self::factory()->comment->create();
     257
     258        update_metadata( 'comment', $comment_id, 'foo', 'bar' );
     259        wp_cache_delete( 'last_changed', 'comment' );
     260
     261        $this->assertTrue( delete_metadata( 'comment', $comment_id, 'foo' ) );
     262        $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) );
     263    }
    227264}
Note: See TracChangeset for help on using the changeset viewer.