Changeset 6243
- Timestamp:
- 10/13/2007 06:23:59 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r6241 r6243 1160 1160 foreach ($terms as $term) { 1161 1161 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) ); 1162 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_tax nomy_id' => $term ) );1162 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 1163 1163 } 1164 1164 … … 1175 1175 1176 1176 function clean_object_term_cache($object_ids, $object_type) { 1177 global $object_term_cache, $blog_id;1178 1179 1177 if ( !is_array($object_ids) ) 1180 1178 $object_ids = array($object_ids); 1181 1179 1182 $taxonomies = get_object_taxonomies($object_type); 1183 1184 foreach ( $object_ids as $id ) { 1185 foreach ( $taxonomies as $taxonomy ) { 1186 if ( isset($object_term_cache[$blog_id][$id][$taxonomy]) ) 1187 unset($object_term_cache[$blog_id][$id][$taxonomy]); 1188 } 1189 } 1180 foreach ( $object_ids as $id ) 1181 wp_cache_delete($id, 'object_terms'); 1190 1182 } 1191 1183 … … 1223 1215 1224 1216 function &get_object_term_cache($id, $taxonomy) { 1225 global $object_term_cache, $blog_id;1226 1227 if ( isset($object_term_cache[$blog_id][$id][$taxonomy]) )1228 return $object_term_cache[$blog_id][$id][$taxonomy];1229 1230 if ( isset($object_term_cache[$blog_id][$id]) )1231 return array();1217 $terms = wp_cache_get($id, 'object_terms'); 1218 if ( false !== $terms ) { 1219 if ( isset($terms[$taxonomy]) ) 1220 return $terms[$taxonomy]; 1221 else 1222 return array(); 1223 } 1232 1224 1233 1225 return false; … … 1235 1227 1236 1228 function update_object_term_cache($object_ids, $object_type) { 1237 global $wpdb , $object_term_cache, $blog_id;1229 global $wpdb; 1238 1230 1239 1231 if ( empty($object_ids) ) … … 1243 1235 $object_ids = explode(',', $object_ids); 1244 1236 1245 $ count = count($object_ids);1246 for ( $i = 0; $i < $count; $i++ ) { 1247 $object_id = (int) $object_ids[ $i ];1248 if ( isset( $object_term_cache[$blog_id][$object_id] )) {1249 unset( $object_ids[ $i ] );1250 continue;1251 1252 } 1253 1254 if ( count( $object_ids ) == 0 )1255 return; 1256 1257 $terms = wp_get_object_terms($object_ids, get_object_taxonomies($object_type), 'fields=all_with_object_id'); 1258 1259 if ( empty($terms))1260 return;1261 1262 foreach ( $ terms as $term )1263 $object_term_cache[$blog_id][$term->object_id][$term->taxonomy][$term->term_id] = $term;1264 1265 foreach ( $object_ids as $id ) {1266 if ( ! isset($object_term_cache[$blog_id][$id]) ) 1267 $object_term_cache[$blog_id][$id] = array();1268 }1237 $object_ids = array_map('intval', $object_ids); 1238 1239 $ids = array(); 1240 foreach ( (array) $object_ids as $id ) { 1241 if ( false === wp_cache_get($id, 'object_terms') ) 1242 $ids[] = $id; 1243 } 1244 1245 if ( empty( $ids ) ) 1246 return false; 1247 1248 $terms = wp_get_object_terms($ids, get_object_taxonomies($object_type), 'fields=all_with_object_id'); 1249 1250 $object_terms = array(); 1251 foreach ( (array) $terms as $term ) 1252 $object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term; 1253 1254 foreach ( $ids as $id ) { 1255 if ( ! isset($object_terms[$id]) ) 1256 $object_terms[$id] = array(); 1257 } 1258 1259 foreach ( $object_terms as $id => $value ) 1260 wp_cache_set($id, $value, 'object_terms'); 1269 1261 } 1270 1262 … … 1394 1386 foreach ( $terms as $term ) { 1395 1387 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term ) ); 1396 $wpdb->update( $wpdb->term_tax nomoy, compact( 'count' ), array( 'term_taxnomy_id' => $term ) );1388 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 1397 1389 } 1398 1390 }
Note: See TracChangeset
for help on using the changeset viewer.