summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-admin/upgrade-functions.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-11-16 11:46:05 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-11-16 11:46:05 +0000
commitb6afd61f8d70c0bdb1201064a5d6e5910d644d91 (patch)
tree2b21b4d4c4eaee0cdf0d1443ac0aa7dffeb51c46 /wp-inst/wp-admin/upgrade-functions.php
parentac41b79ab6266ccd35d1ebf747e4135d53d04035 (diff)
downloadwordpress-mu-b6afd61f8d70c0bdb1201064a5d6e5910d644d91.tar.gz
wordpress-mu-b6afd61f8d70c0bdb1201064a5d6e5910d644d91.tar.xz
wordpress-mu-b6afd61f8d70c0bdb1201064a5d6e5910d644d91.zip
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@436 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-admin/upgrade-functions.php')
-rw-r--r--wp-inst/wp-admin/upgrade-functions.php29
1 files changed, 27 insertions, 2 deletions
diff --git a/wp-inst/wp-admin/upgrade-functions.php b/wp-inst/wp-admin/upgrade-functions.php
index 0a9b0e0..bfb16ef 100644
--- a/wp-inst/wp-admin/upgrade-functions.php
+++ b/wp-inst/wp-admin/upgrade-functions.php
@@ -31,7 +31,7 @@ function upgrade_all() {
upgrade_130();
}
- if ( $wp_current_db_version < 2966 )
+ if ( $wp_current_db_version < 3104 )
upgrade_160();
save_mod_rewrite_rules();
@@ -307,10 +307,35 @@ function upgrade_160() {
if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
$categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
foreach ( $categories as $cat_id ) {
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat WHERE category_id = '$cat_id'");
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'");
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
}
}
+
+ // populate comment_count field of posts table
+ $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments GROUP BY comment_post_ID" );
+ if( is_array( $comments ) ) {
+ foreach ($comments as $comment) {
+ $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID}'" );
+ }
+ }
+
+ // Some alpha versions used a post status of object instead of attachment and put
+ // the mime type in post_type instead of post_mime_type.
+ if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
+ $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
+ foreach ($objects as $object) {
+ $wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment',
+ post_mime_type = '$object->post_type',
+ post_type = '',
+ guid = '$guid'
+ WHERE ID = $object->ID");
+
+ $meta = get_post_meta($postid, 'imagedata', true);
+ if ( ! empty($meta['file']) )
+ add_post_meta($object->ID, '_wp_attached_file', $meta['file']);
+ }
+ }
}
// The functions we use to actually do stuff