Ticket #6836: 6836.3.diff
File 6836.3.diff, 21.7 KB (added by , 17 years ago) |
---|
-
wp-admin/includes/schema.php
258 258 259 259 // Set up a few options not to load by default 260 260 $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); 261 foreach ($fatoptions as $fatoption) : 262 $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'"); 263 endforeach; 261 foreach ($fatoptions as $fatoption) 262 $wpdb->update( $wpdb->options, array('autoload' => 'no'), array('option_name' => $fatoption) ); 264 263 } 265 264 266 265 function populate_roles() { … … 423 422 } 424 423 } 425 424 426 ?> 425 ?> 426 No newline at end of file -
wp-admin/includes/upgrade.php
61 61 global $wpdb; 62 62 63 63 // Default category 64 $cat_name = $wpdb->escape(__('Uncategorized'));64 $cat_name = __('Uncategorized'); 65 65 $cat_slug = sanitize_title(_c('Uncategorized|Default category slug')); 66 $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')"); 67 $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('1', 'category', '', '0', '1')"); 66 67 $wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) ); 68 $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '1', 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); 68 69 69 70 // Default link category 70 $cat_name = $wpdb->escape(__('Blogroll'));71 $cat_name = __('Blogroll'); 71 72 $cat_slug = sanitize_title(_c('Blogroll|Default link category slug')); 72 $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')"); 73 $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('2', 'link_category', '', '0', '7')"); 73 74 $wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) ); 75 $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '2', 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7)); 74 76 75 77 // Now drop in some default links 76 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://codex.wordpress.org/', 'Documentation', 0, '', '');"); 77 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 2)" ); 78 $default_links = array(); 79 $default_links[] = array( 'link_url' => 'http://codex.wordpress.org/', 80 'link_name' => 'Documentation', 81 'link_category' => 0, 82 'link_rss' => '', 83 'link_notes' => ''); 78 84 79 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/development/', 'Development Blog', 0, 'http://wordpress.org/development/feed/', '');"); 80 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (2, 2)" ); 85 $default_links[] = array( 'link_url' => 'http://wordpress.org/development/', 86 'link_name' => 'Development Blog', 87 'link_category' => 0, 88 'link_rss' => 'http://wordpress.org/development/feed/', 89 'link_notes' => ''); 81 90 82 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/ideas/', 'Suggest Ideas', 0, '', '');"); 83 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (3, 2)" ); 91 $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/ideas/', 92 'link_name' => 'Suggest Ideas', 93 'link_category' => 0, 94 'link_rss' => '', 95 'link_notes' =>''); 84 96 85 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/support/', 'Support Forum', 0, '', '');"); 86 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (4, 2)" ); 97 $default_links[] = array( 'link_url' => 'http://wordpress.org/support/', 98 'link_name' => 'Support Forum', 99 'link_category' => 0, 100 'link_rss' => '', 101 'link_notes' =>''); 87 102 88 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/plugins/', 'Plugins', 0, '', '');"); 89 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (5, 2)" ); 103 $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/plugins/', 104 'link_name' => 'Plugins', 105 'link_category' => 0, 106 'link_rss' => '', 107 'link_notes' =>''); 90 108 91 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/themes/', 'Themes', 0, '', '');"); 92 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (6, 2)" ); 109 $default_links[] = array( 'link_url' => 'http://wordpress.org/extend/themes/', 110 'link_name' => 'Themes', 111 'link_category' => 0, 112 'link_rss' => '', 113 'link_notes' =>''); 93 114 94 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://planet.wordpress.org/', 'WordPress Planet', 0, '', '');"); 95 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (7, 2)" ); 115 $default_links[] = array( 'link_url' => 'http://planet.wordpress.org/', 116 'link_name' => 'WordPress Planet', 117 'link_category' => 0, 118 'link_rss' => '', 119 'link_notes' =>''); 120 foreach($default_links as $link){ 121 $wpdb->insert( $wpdb->links, $link); 122 $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => 2, 'object_id' => $wpdb->insert_id) ); 123 } 96 124 97 125 // First post 98 126 $now = date('Y-m-d H:i:s'); 99 127 $now_gmt = gmdate('Y-m-d H:i:s'); 100 128 $first_post_guid = get_option('home') . '/?p=1'; 101 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(_c('hello-world|Default post slug'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')"); 102 $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 1)" ); 129 130 $wpdb->insert( $wpdb->posts, array( 131 'post_author' => $user_id, 132 'post_date' => $now, 133 'post_date_gmt' => $now_gmt, 134 'post_content' => __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'), 135 'post_excerpt' => '', 136 'post_title' => __('Hello world!'), 137 'post_category' => 0, 138 'post_name' => _c('hello-world|Default post slug'), 139 'post_modified' => $now, 140 'post_modified_gmt' => $now_gmt, 141 'guid' => $first_post_guid, 142 'comment_count' => 1, 143 'to_ping' => '', 144 'pinged' => '', 145 'post_content_filtered' => '' 146 )); 147 $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => 1, 'object_id' => 1) ); 103 148 104 149 // Default comment 105 $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.'))."')"); 106 150 $wpdb->insert( $wpdb->comments, array( 151 'comment_post_ID' => 1, 152 'comment_author' => __('Mr WordPress'), 153 'comment_author_email' => '', 154 'comment_author_url' => 'http://wordpress.org/', 155 'comment_date' => $now, 156 'comment_date_gmt' => $now_gmt, 157 'comment_content' => __('Hi, this is a comment.<br />To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.') 158 )); 107 159 // First Page 108 160 $first_post_guid = get_option('home') . '/?page_id=2'; 109 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(_c('about|Default page slug'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')"); 161 $wpdb->insert( $wpdb->posts, array( 162 'post_author' => $user_id, 163 'post_date' => $now, 164 'post_date_gmt' => $now_gmt, 165 'post_content' => __('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'), 166 'post_excerpt' => '', 167 'post_title' => __('About'), 168 'post_category' => '', 169 'post_name' => _c('about|Default page slug'), 170 'post_modified' => $now, 171 'post_modified_gmt' => $now_gmt, 172 'guid' => $first_post_guid, 173 'post_type' => 'page', 174 'to_ping' => '', 175 'pinged' => '', 176 'post_content_filtered' => '' 177 )); 110 178 } 111 179 endif; 112 180 … … 230 298 foreach ($categories as $category) { 231 299 if ('' == $category->category_nicename) { 232 300 $newtitle = sanitize_title($category->cat_name); 233 $wpdb ->query( $wpdb->prepare("UPDATE $wpdb->categories SET category_nicename = %s WHERE cat_ID = %d", $newtitle,$category->cat_ID) );301 $wpdb>update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) ); 234 302 } 235 303 } 236 304 … … 255 323 // Check to see if it's already been imported 256 324 $cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) ); 257 325 if (!$cat && 0 != $post->post_category) { // If there's no result 258 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->post2cat 259 (post_id, category_id) 260 VALUES (%s, %s) 261 ", $post->ID, $post->post_category) ); 326 $wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) ); 262 327 } 263 328 } 264 329 endif; … … 286 351 foreach ($users as $user) { 287 352 if ('' == $user->user_nicename) { 288 353 $newname = sanitize_title($user->user_nickname); 289 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->users SET user_nicename = %s WHERE ID = %d", $newname,$user->ID) );354 $wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) ); 290 355 } 291 356 } 292 357 293 358 $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); 294 359 foreach ($users as $row) { 295 360 if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { 296 $wpdb-> query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');361 $wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) ); 297 362 } 298 363 } 299 364 … … 349 414 else 350 415 $guid = $post->guid; 351 416 352 $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'"); 417 $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); 418 353 419 } 354 420 } 355 421 … … 357 423 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); 358 424 if ($comments) { 359 425 foreach($comments as $comment) { 360 $comment_content = addslashes(deslash($comment->comment_content)); 361 $comment_author = addslashes(deslash($comment->comment_author)); 362 $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'"); 426 $comment_content = deslash($comment->comment_content); 427 $comment_author = deslash($comment->comment_author); 428 429 $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) ); 363 430 } 364 431 } 365 432 … … 367 434 $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); 368 435 if ($links) { 369 436 foreach($links as $link) { 370 $link_name = addslashes(deslash($link->link_name)); 371 $link_description = addslashes(deslash($link->link_description)); 372 $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'"); 437 $link_name = deslash($link->link_name); 438 $link_description = deslash($link->link_description); 439 440 $wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) ); 373 441 } 374 442 } 375 443 376 444 // The "paged" option for what_to_show is no more. 377 if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') { 378 $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'"); 379 } 445 if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') 446 $wpdb->update( $wpdb->options, array('option_value' => 'posts'), array('option_name' => 'what_to_show') ); 380 447 381 448 $active_plugins = __get_option('active_plugins'); 382 449 … … 446 513 if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; 447 514 if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; 448 515 if (!$idmode) $id = $user->user_nickname; 449 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->users SET display_name = %s WHERE ID = %d", $id,$user->ID) );516 $wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) ); 450 517 endif; 451 518 452 519 // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. … … 466 533 467 534 // populate comment_count field of posts table 468 535 $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); 469 if( is_array( $comments ) ) { 470 foreach ($comments as $comment) { 471 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_count = %d WHERE ID = %d", $comment->c, $comment->comment_post_ID) ); 472 } 473 } 536 if( is_array( $comments ) ) 537 foreach ($comments as $comment) 538 $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); 474 539 475 540 // Some alpha versions used a post status of object instead of attachment and put 476 541 // the mime type in post_type instead of post_mime_type. 477 542 if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { 478 543 $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'"); 479 544 foreach ($objects as $object) { 480 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status ='attachment',481 post_mime_type = %s,482 post_type = ''483 WHERE ID = %d", $object->post_type, $object->ID) );545 $wpdb->update( $wpdb->posts, array( 'post_status' => 'attachment', 546 'post_mime_type' => $object->post_type, 547 'post_type' => ''), 548 array( 'ID' => $object->ID ) ); 484 549 485 550 $meta = get_post_meta($object->ID, 'imagedata', true); 486 551 if ( ! empty($meta['file']) ) … … 558 623 559 624 if ( empty( $term_group ) ) { 560 625 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; 561 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group,$id) );626 $wpdb->update( $wpdb->terms, compact('term_group'), array('term_id' => $id) ); 562 627 } 563 628 } 564 629 565 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES 566 (%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) ); 630 $wpdb->insert( $wpdb->terms, compact('term_id', 'name', 'slug', 'term_group') ); 567 631 568 632 $count = 0; 569 633 if ( !empty($category->category_count) ) { 570 634 $count = (int) $category->category_count; 571 635 $taxonomy = 'category'; 572 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );636 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 573 637 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 574 638 } 575 639 576 640 if ( !empty($category->link_count) ) { 577 641 $count = (int) $category->link_count; 578 642 $taxonomy = 'link_category'; 579 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );643 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 580 644 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 581 645 } 582 646 … … 584 648 $have_tags = true; 585 649 $count = (int) $category->tag_count; 586 650 $taxonomy = 'post_tag'; 587 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );651 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 588 652 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 589 653 } 590 654 591 655 if ( empty($count) ) { 592 656 $count = 0; 593 657 $taxonomy = 'category'; 594 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );658 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 595 659 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 596 660 } 597 661 } … … 611 675 if ( empty($tt_id) ) 612 676 continue; 613 677 614 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $post_id,$tt_id) );678 $wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) ); 615 679 } 616 680 617 681 // < 3570 we used linkcategories. >= 3570 we used categories and link2cat. … … 636 700 } 637 701 638 702 if ( empty($term_id) ) { 639 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES (%s, %s, %d)", $name, $slug, $term_group) );703 $wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') ); 640 704 $term_id = (int) $wpdb->insert_id; 641 705 } 642 706 643 707 $link_cat_id_map[$cat_id] = $term_id; 644 708 $default_link_cat = $term_id; 645 709 646 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES (%d, 'link_category', '', '0', '0')", $term_id) );710 $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) ); 647 711 $tt_ids[$term_id] = (int) $wpdb->insert_id; 648 712 } 649 713 … … 659 723 if ( empty($tt_id) ) 660 724 continue; 661 725 662 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $link->link_id,$tt_id) );726 $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) ); 663 727 } 664 728 665 729 // Set default to the last category we grabbed during the upgrade loop. … … 673 737 $tt_id = $tt_ids[$term_id][$taxonomy]; 674 738 if ( empty($tt_id) ) 675 739 continue; 676 677 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $link_id, $tt_id) ); 740 $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) ); 678 741 } 679 742 } 680 743 … … 690 753 $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->term_taxonomy_id) ); 691 754 else 692 755 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); 693 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET count = %d WHERE term_taxonomy_id = %d", $count,$term->term_taxonomy_id) );756 $wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) ); 694 757 } 695 758 } 696 759 … … 713 776 function upgrade_old_slugs() { 714 777 // upgrade people who were using the Redirect Old Slugs plugin 715 778 global $wpdb; 716 $wpdb-> query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");779 $wpdb->update( $wpdb->postmeta, array('meta_key' => '_wp_old_slug'), array('meta_key' => 'old_slug') ); 717 780 } 718 781 719 782 720 783 function upgrade_250() { 721 784 global $wp_current_db_version; 722 785 723 if ( $wp_current_db_version < 6689 ) {786 if ( $wp_current_db_version < 6689 ) 724 787 populate_roles_250(); 725 }726 727 788 } 728 789 729 790 function upgrade_251() {