Changeset 53549 for trunk/src/wp-includes/query.php
- Timestamp:
- 06/21/2022 01:32:48 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r53429 r53549 1151 1151 } 1152 1152 1153 $id = (int) $wpdb->get_var( $query ); 1153 $key = md5( $query ); 1154 $last_changed = wp_cache_get_last_changed( 'posts' ); 1155 $cache_key = "find_post_by_old_slug:$key:$last_changed"; 1156 $cache = wp_cache_get( $cache_key, 'posts' ); 1157 if ( false !== $cache ) { 1158 $id = $cache; 1159 } else { 1160 $id = (int) $wpdb->get_var( $query ); 1161 wp_cache_set( $cache_key, $id, 'posts' ); 1162 } 1154 1163 1155 1164 return $id; … … 1184 1193 $id = 0; 1185 1194 if ( $date_query ) { 1186 $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta AS pm_date, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_date' AND post_name = %s" . $date_query, $post_type, get_query_var( 'name' ) ) ); 1187 1188 if ( ! $id ) { 1189 // Check to see if an old slug matches the old date. 1190 $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts, $wpdb->postmeta AS pm_slug, $wpdb->postmeta AS pm_date WHERE ID = pm_slug.post_id AND ID = pm_date.post_id AND post_type = %s AND pm_slug.meta_key = '_wp_old_slug' AND pm_slug.meta_value = %s AND pm_date.meta_key = '_wp_old_date'" . $date_query, $post_type, get_query_var( 'name' ) ) ); 1195 $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta AS pm_date, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_date' AND post_name = %s" . $date_query, $post_type, get_query_var( 'name' ) ); 1196 $key = md5( $query ); 1197 $last_changed = wp_cache_get_last_changed( 'posts' ); 1198 $cache_key = "find_post_by_old_date:$key:$last_changed"; 1199 $cache = wp_cache_get( $cache_key, 'posts' ); 1200 if ( false !== $cache ) { 1201 $id = $cache; 1202 } else { 1203 $id = (int) $wpdb->get_var( $query ); 1204 if ( ! $id ) { 1205 // Check to see if an old slug matches the old date. 1206 $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts, $wpdb->postmeta AS pm_slug, $wpdb->postmeta AS pm_date WHERE ID = pm_slug.post_id AND ID = pm_date.post_id AND post_type = %s AND pm_slug.meta_key = '_wp_old_slug' AND pm_slug.meta_value = %s AND pm_date.meta_key = '_wp_old_date'" . $date_query, $post_type, get_query_var( 'name' ) ) ); 1207 } 1208 wp_cache_set( $cache_key, $id, 'posts' ); 1191 1209 } 1192 1210 }
Note: See TracChangeset
for help on using the changeset viewer.