From 05b22769e9774f1ce006cc91ab409d59cc025b3c Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 21 Nov 2013 19:31:10 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@26307 git-svn-id: http://core.svn.wordpress.org/trunk@26211 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/meta.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 82cb49144a..55beadb1a4 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -558,9 +558,9 @@ function update_meta_cache($meta_type, $object_ids) { return $cache; // Get meta info - $id_list = join(',', $ids); - $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list)", - $meta_type), ARRAY_A ); + $id_list = join( ',', $ids ); + $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; + $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A ); if ( !empty($meta_list) ) { foreach ( $meta_list as $metarow) {