Make WordPress Core


Ignore:
Timestamp:
11/21/2013 07:30:35 PM (11 years ago)
Author:
wonderboymusic
Message:

In update_meta_cache(), ensure that meta is always stored in the same order. Removes an unnecessary $wpdb->prepare statement. Adds unit test.

Props mattheu.
Fixes #25511.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/meta.php

    r25255 r26307  
    172172        $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) );
    173173    }
     174
     175    function test_meta_cache_order_asc() {
     176        $post_id = $this->factory->post->create();
     177        $colors = array( 'red', 'blue', 'yellow', 'green' );
     178        foreach ( $colors as $color )
     179            add_post_meta( $post_id, 'color', $color );
     180
     181        foreach ( range( 1, 10 ) as $i ) {
     182            $meta = get_post_meta( $post_id, 'color' );
     183            $this->assertEquals( $meta, $colors );
     184
     185            if ( 0 === $i % 2 )
     186                wp_cache_delete( $post_id, 'post_meta' );
     187        }
     188    }
    174189}
Note: See TracChangeset for help on using the changeset viewer.