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/post/meta.php

    r43571 r43982  
    310310        );
    311311    }
     312
     313    /**
     314     * @ticket 44467
     315     */
     316    public function test_add_metadata_sets_posts_last_changed() {
     317        $post_id = self::factory()->post->create();
     318
     319        wp_cache_delete( 'last_changed', 'posts' );
     320
     321        $this->assertInternalType( 'integer', add_metadata( 'post', $post_id, 'foo', 'bar' ) );
     322        $this->assertNotFalse( wp_cache_get_last_changed( 'posts' ) );
     323    }
     324
     325    /**
     326     * @ticket 44467
     327     */
     328    public function test_update_metadata_sets_posts_last_changed() {
     329        $post_id = self::factory()->post->create();
     330
     331        wp_cache_delete( 'last_changed', 'posts' );
     332
     333        $this->assertInternalType( 'integer', update_metadata( 'post', $post_id, 'foo', 'bar' ) );
     334        $this->assertNotFalse( wp_cache_get_last_changed( 'posts' ) );
     335    }
     336
     337    /**
     338     * @ticket 44467
     339     */
     340    public function test_delete_metadata_sets_posts_last_changed() {
     341        $post_id = self::factory()->post->create();
     342
     343        update_metadata( 'post', $post_id, 'foo', 'bar' );
     344        wp_cache_delete( 'last_changed', 'posts' );
     345
     346        $this->assertTrue( delete_metadata( 'post', $post_id, 'foo' ) );
     347        $this->assertNotFalse( wp_cache_get_last_changed( 'posts' ) );
     348    }
    312349}
Note: See TracChangeset for help on using the changeset viewer.