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

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