Ticket #6836: 6836.full.diff
File 6836.full.diff, 38.0 KB (added by , 16 years ago) |
---|
-
wp-admin/import/wp-cat2tag.php
300 300 } 301 301 302 302 // Change the category to a tag. 303 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET taxonomy = 'post_tag' WHERE term_id = %d AND taxonomy = 'category'", $category->term_id) );303 $wpdb->update($wpdb->term_taxonomy, array('taxonomy' => 'post_tag'), array('term_id' => $category->term_id, 'taxonomy' => 'category') ); 304 304 305 305 $terms = $wpdb->get_col( $wpdb->prepare("SELECT term_id FROM $wpdb->term_taxonomy WHERE parent = %d AND taxonomy = 'category'", $category->term_id) ); 306 306 foreach ( (array) $terms as $term ) 307 307 clean_category_cache($term); 308 308 309 309 // Set all parents to 0 (root-level) if their parent was the converted tag 310 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET parent = 0 WHERE parent = %d AND taxonomy = 'category'", $category->term_id) );310 $wpdb->update($wpdb->term_taxonomy, array('parent' => '0'), array('parent' => $category->term_id, 'taxonomy' => 'category') ); 311 311 } 312 312 // Clean the cache 313 313 clean_category_cache($category->term_id); -
wp-admin/includes/bookmark.php
119 119 } 120 120 121 121 if ( $update ) { 122 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_url = %s, 123 link_name = %s, link_image = %s, link_target = %s, 124 link_visible = %s, link_description = %s, link_rating = %s, 125 link_rel = %s, link_notes = %s, link_rss = %s 126 WHERE link_id = %s", $link_url, $link_name, $link_image, $link_target, $link_visible, $link_description, $link_rating, $link_rel, $link_notes, $link_rss, $link_id) ); 122 $wpdb->update( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id') ); 127 123 } else { 128 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", 129 $link_url,$link_name, $link_image, $link_target, $link_description, $link_visible, $link_owner, $link_rating, $link_rel, $link_notes, $link_rss) ); 124 $wpdb->insert( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss') ); 130 125 $link_id = (int) $wpdb->insert_id; 131 126 } 132 127 -
wp-admin/includes/post.php
326 326 327 327 $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' ); 328 328 329 $metakeyselect = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) ); 330 $metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) ); 331 $metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) )); 332 $metavalue = $wpdb->escape( $metavalue ); 329 $metakeyselect = stripslashes( trim( $_POST['metakeyselect'] ) ); 330 $metakeyinput = stripslashes( trim( $_POST['metakeyinput'] ) ); 331 $meta_value = maybe_serialize( stripslashes( trim( $_POST['metavalue'] ) ) ); 333 332 334 if ( ('0' === $meta value || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {333 if ( ('0' === $meta_value || !empty ( $meta_value ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) { 335 334 // We have a key/value pair. If both the select and the 336 335 // input for the key have data, the input takes precedence: 337 336 338 337 if ('#NONE#' != $metakeyselect) 339 $meta key = $metakeyselect;338 $meta_key = $metakeyselect; 340 339 341 340 if ( $metakeyinput) 342 $meta key = $metakeyinput; // default341 $meta_key = $metakeyinput; // default 343 342 344 if ( in_array($meta key, $protected) )343 if ( in_array($meta_key, $protected) ) 345 344 return false; 346 345 347 346 wp_cache_delete($post_ID, 'post_meta'); 348 347 349 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->postmeta 350 (post_id,meta_key,meta_value ) VALUES (%s, %s, %s)", 351 $post_ID, $metakey, $metavalue) ); 348 $wpdb->insert( $wpdb->postmeta, compact('post_ID', 'meta_key', 'meta_value')); 349 352 350 return $wpdb->insert_id; 353 351 } 354 352 return false; … … 467 465 global $wpdb; 468 466 $old_ID = (int) $old_ID; 469 467 $new_ID = (int) $new_ID; 470 return $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE post_parent = %d", $new_ID,$old_ID) );468 return $wpdb->update($wpdb->posts, array('post_parent' => $new_ID), array('post_parent' => $old_ID) ); 471 469 } 472 470 473 471 function get_available_post_statuses($type = 'post') { -
wp-admin/includes/schema.php
264 264 265 265 // Set up a few options not to load by default 266 266 $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); 267 foreach ($fatoptions as $fatoption) : 268 $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'"); 269 endforeach; 267 foreach ($fatoptions as $fatoption) 268 $wpdb->update( $wpdb->options, array('autoload' => 'no'), array('option_name' => $fatoption) ); 270 269 } 271 270 272 271 function populate_roles() { -
wp-admin/includes/template.php
520 520 // catch and repair bad pages 521 521 if ( $page->post_parent == $page->ID ) { 522 522 $page->post_parent = 0; 523 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d",$page->ID) );523 $wpdb->update($wpdb->posts, array('post_parent' => '0'), array('ID' => $page->ID) ); 524 524 clean_page_cache( $page->ID ); 525 525 } 526 526 -
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 … … 236 304 foreach ($categories as $category) { 237 305 if ('' == $category->category_nicename) { 238 306 $newtitle = sanitize_title($category->cat_name); 239 $wpdb ->query( $wpdb->prepare("UPDATE $wpdb->categories SET category_nicename = %s WHERE cat_ID = %d", $newtitle,$category->cat_ID) );307 $wpdb>update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) ); 240 308 } 241 309 } 242 310 … … 261 329 // Check to see if it's already been imported 262 330 $cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) ); 263 331 if (!$cat && 0 != $post->post_category) { // If there's no result 264 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->post2cat 265 (post_id, category_id) 266 VALUES (%s, %s) 267 ", $post->ID, $post->post_category) ); 332 $wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) ); 268 333 } 269 334 } 270 335 endif; … … 292 357 foreach ($users as $user) { 293 358 if ('' == $user->user_nicename) { 294 359 $newname = sanitize_title($user->user_nickname); 295 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->users SET user_nicename = %s WHERE ID = %d", $newname,$user->ID) );360 $wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) ); 296 361 } 297 362 } 298 363 299 364 $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); 300 365 foreach ($users as $row) { 301 366 if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { 302 $wpdb-> query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');367 $wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) ); 303 368 } 304 369 } 305 370 … … 355 420 else 356 421 $guid = $post->guid; 357 422 358 $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'"); 423 $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); 424 359 425 } 360 426 } 361 427 … … 363 429 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); 364 430 if ($comments) { 365 431 foreach($comments as $comment) { 366 $comment_content = addslashes(deslash($comment->comment_content)); 367 $comment_author = addslashes(deslash($comment->comment_author)); 368 $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'"); 432 $comment_content = deslash($comment->comment_content); 433 $comment_author = deslash($comment->comment_author); 434 435 $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) ); 369 436 } 370 437 } 371 438 … … 373 440 $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); 374 441 if ($links) { 375 442 foreach($links as $link) { 376 $link_name = addslashes(deslash($link->link_name)); 377 $link_description = addslashes(deslash($link->link_description)); 378 $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'"); 443 $link_name = deslash($link->link_name); 444 $link_description = deslash($link->link_description); 445 446 $wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) ); 379 447 } 380 448 } 381 449 382 450 // The "paged" option for what_to_show is no more. 383 if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') { 384 $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'"); 385 } 451 if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') 452 $wpdb->update( $wpdb->options, array('option_value' => 'posts'), array('option_name' => 'what_to_show') ); 386 453 387 454 $active_plugins = __get_option('active_plugins'); 388 455 … … 452 519 if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; 453 520 if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; 454 521 if (!$idmode) $id = $user->user_nickname; 455 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->users SET display_name = %s WHERE ID = %d", $id,$user->ID) );522 $wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) ); 456 523 endif; 457 524 458 525 // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. … … 472 539 473 540 // populate comment_count field of posts table 474 541 $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); 475 if( is_array( $comments ) ) { 476 foreach ($comments as $comment) { 477 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_count = %d WHERE ID = %d", $comment->c, $comment->comment_post_ID) ); 478 } 479 } 542 if( is_array( $comments ) ) 543 foreach ($comments as $comment) 544 $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); 480 545 481 546 // Some alpha versions used a post status of object instead of attachment and put 482 547 // the mime type in post_type instead of post_mime_type. 483 548 if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { 484 549 $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'"); 485 550 foreach ($objects as $object) { 486 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status ='attachment',487 post_mime_type = %s,488 post_type = ''489 WHERE ID = %d", $object->post_type, $object->ID) );551 $wpdb->update( $wpdb->posts, array( 'post_status' => 'attachment', 552 'post_mime_type' => $object->post_type, 553 'post_type' => ''), 554 array( 'ID' => $object->ID ) ); 490 555 491 556 $meta = get_post_meta($object->ID, 'imagedata', true); 492 557 if ( ! empty($meta['file']) ) … … 564 629 565 630 if ( empty( $term_group ) ) { 566 631 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; 567 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group,$id) );632 $wpdb->update( $wpdb->terms, compact('term_group'), array('term_id' => $id) ); 568 633 } 569 634 } 570 635 571 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES 572 (%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) ); 636 $wpdb->insert( $wpdb->terms, compact('term_id', 'name', 'slug', 'term_group') ); 573 637 574 638 $count = 0; 575 639 if ( !empty($category->category_count) ) { 576 640 $count = (int) $category->category_count; 577 641 $taxonomy = 'category'; 578 $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) );642 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 579 643 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 580 644 } 581 645 582 646 if ( !empty($category->link_count) ) { 583 647 $count = (int) $category->link_count; 584 648 $taxonomy = 'link_category'; 585 $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) );649 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 586 650 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 587 651 } 588 652 … … 590 654 $have_tags = true; 591 655 $count = (int) $category->tag_count; 592 656 $taxonomy = 'post_tag'; 593 $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) );657 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 594 658 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 595 659 } 596 660 597 661 if ( empty($count) ) { 598 662 $count = 0; 599 663 $taxonomy = 'category'; 600 $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) );664 $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); 601 665 $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; 602 666 } 603 667 } … … 617 681 if ( empty($tt_id) ) 618 682 continue; 619 683 620 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $post_id,$tt_id) );684 $wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) ); 621 685 } 622 686 623 687 // < 3570 we used linkcategories. >= 3570 we used categories and link2cat. … … 642 706 } 643 707 644 708 if ( empty($term_id) ) { 645 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES (%s, %s, %d)", $name, $slug, $term_group) );709 $wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') ); 646 710 $term_id = (int) $wpdb->insert_id; 647 711 } 648 712 649 713 $link_cat_id_map[$cat_id] = $term_id; 650 714 $default_link_cat = $term_id; 651 715 652 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES (%d, 'link_category', '', '0', '0')", $term_id) );716 $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) ); 653 717 $tt_ids[$term_id] = (int) $wpdb->insert_id; 654 718 } 655 719 … … 665 729 if ( empty($tt_id) ) 666 730 continue; 667 731 668 $wpdb-> query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $link->link_id,$tt_id) );732 $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) ); 669 733 } 670 734 671 735 // Set default to the last category we grabbed during the upgrade loop. … … 679 743 $tt_id = $tt_ids[$term_id][$taxonomy]; 680 744 if ( empty($tt_id) ) 681 745 continue; 682 683 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ( %d, %d)", $link_id, $tt_id) ); 746 $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) ); 684 747 } 685 748 } 686 749 … … 696 759 $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) ); 697 760 else 698 761 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); 699 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->term_taxonomy SET count = %d WHERE term_taxonomy_id = %d", $count,$term->term_taxonomy_id) );762 $wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) ); 700 763 } 701 764 } 702 765 … … 719 782 function upgrade_old_slugs() { 720 783 // upgrade people who were using the Redirect Old Slugs plugin 721 784 global $wpdb; 722 $wpdb-> query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");785 $wpdb->update( $wpdb->postmeta, array('meta_key' => '_wp_old_slug'), array('meta_key' => 'old_slug') ); 723 786 } 724 787 725 788 726 789 function upgrade_250() { 727 790 global $wp_current_db_version; 728 791 729 if ( $wp_current_db_version < 6689 ) {792 if ( $wp_current_db_version < 6689 ) 730 793 populate_roles_250(); 731 }732 733 794 } 734 795 735 796 function upgrade_251() { -
wp-admin/includes/user.php
258 258 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->links WHERE link_owner = %d", $id) ); 259 259 } else { 260 260 $reassign = (int) $reassign; 261 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign,$id) );262 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d}", $reassign,$id) );261 $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); 262 $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); 263 263 } 264 264 265 265 // FINALLY, delete user -
wp-admin/update-links.php
36 36 $returns = explode("\n", $body); 37 37 38 38 foreach ($returns as $return) : 39 $time = substr($return, 0, 19); 40 $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return); 41 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) ); 39 $link_updated = substr($return, 0, 19); 40 $link_url = preg_replace('/(.*?) | (.*?)/', '$2', $return); 41 42 $wpdb->update( $wpdb->links, compact('link_updated'), compact('link_url') ); 42 43 endforeach; 43 44 } 44 45 ?> -
wp-includes/comment.php
602 602 if ( ! isset($user_id) ) 603 603 $user_id = 0; 604 604 605 $result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->comments 606 (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id) 607 VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d)", 608 $comment_post_ID, $comment_author, $comment_author_email, $comment_author_url, $comment_author_IP, $comment_date, $comment_date_gmt, $comment_content, $comment_approved, $comment_agent, $comment_type, $comment_parent, $user_id) ); 605 $wpdb->insert($wpdb->comments, compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id')); 609 606 610 607 $id = (int) $wpdb->insert_id; 611 608 … … 728 725 function wp_set_comment_status($comment_id, $comment_status) { 729 726 global $wpdb; 730 727 728 $update = false; 731 729 switch ( $comment_status ) { 732 730 case 'hold': 733 $ query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID = %d LIMIT 1", $comment_id);731 $update = array('comment_approved' => '0'); 734 732 break; 735 733 case 'approve': 736 $ query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID = %d LIMIT 1", $comment_id);734 $update = array('comment_approved' => '1'); 737 735 if ( get_option('comments_notify') ) { 738 736 $comment = get_comment($comment_id); 739 737 wp_notify_postauthor($comment_id, $comment->comment_type); 740 738 } 741 739 break; 742 740 case 'spam': 743 $ query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID = %d LIMIT 1", $comment_id);741 $update = array('comment_approved' => 'spam'); 744 742 break; 745 743 case 'delete': 746 744 return wp_delete_comment($comment_id); … … 749 747 return false; 750 748 } 751 749 752 if ( ! $wpdb->query($query) )750 if ( ! $update || ! $wpdb->update($wpdb->comments, $update, array('comment_ID' => $comment_id)) ) 753 751 return false; 754 752 755 753 clean_comment_cache($comment_id); … … 794 792 795 793 $comment_date_gmt = get_gmt_from_date($comment_date); 796 794 797 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->comments SET 798 comment_content = %s, 799 comment_author = %s, 800 comment_author_email = %s, 801 comment_approved = %s, 802 comment_author_url = %s, 803 comment_date = %s, 804 comment_date_gmt = %s 805 WHERE comment_ID = %d", 806 $comment_content, 807 $comment_author, 808 $comment_author_email, 809 $comment_approved, 810 $comment_author_url, 811 $comment_date, 812 $comment_date_gmt, 813 $comment_ID) ); 795 $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_author_url', 'comment_date', 'comment_date_gmt'), compact('comment_ID') ); 814 796 815 797 $rval = $wpdb->rows_affected; 816 798 … … 1070 1052 $to_ping = get_to_ping($post_id); 1071 1053 $pinged = get_pung($post_id); 1072 1054 if ( empty($to_ping) ) { 1073 $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = %d", $post_id) );1055 $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) ); 1074 1056 return; 1075 1057 } 1076 1058 -
wp-includes/functions.php
328 328 wp_cache_set( $option_name, $newvalue, 'options' ); 329 329 } 330 330 331 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->options SET option_value = %s WHERE option_name = %s", $newvalue, $option_name ) ); 331 $wpdb->update($wpdb->options, array('option_value' => $newvalue), array('option_name' => $option_name) ); 332 332 333 if ( $wpdb->rows_affected == 1 ) { 333 334 do_action( "update_option_{$option_name}", $oldvalue, $_newvalue ); 334 335 return true; … … 370 371 wp_cache_set( 'notoptions', $notoptions, 'options' ); 371 372 } 372 373 373 $wpdb-> query( $wpdb->prepare( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES (%s, %s, %s)", $name, $value, $autoload) );374 $wpdb->insert($wpdb->options, array('option_name' => $name, 'option_value' => $value, 'autoload' => $autoload) ); 374 375 375 376 do_action( "add_option_{$name}", $name, $value ); 376 377 return; … … 524 525 if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) { 525 526 if ( $headers = wp_get_http_headers( $url) ) { 526 527 $len = (int) $headers['content-length']; 527 $type = $ wpdb->escape( $headers['content-type'] );528 $type = $headers['content-type']; 528 529 $allowed_types = array( 'video', 'audio' ); 529 530 if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { 530 531 $meta_value = "$url\n$len\n$type\n"; 531 $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) 532 VALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value ) ); 532 $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) ); 533 533 } 534 534 } 535 535 } -
wp-includes/pluggable.php
1234 1234 global $wpdb; 1235 1235 1236 1236 $hash = wp_hash_password($password); 1237 $ query = $wpdb->prepare("UPDATE $wpdb->users SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $hash, $user_id);1238 $wpdb->query($query); 1237 $wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) ); 1238 1239 1239 wp_cache_delete($user_id, 'users'); 1240 1240 } 1241 1241 endif; -
wp-includes/post.php
371 371 global $wpdb; 372 372 373 373 $post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db'); 374 $return = $wpdb-> query( $wpdb->prepare("UPDATE $wpdb->posts SET post_type = %s WHERE ID = %d", $post_type,$post_id) );374 $return = $wpdb->update($wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) ); 375 375 376 376 if ( 'page' == $post_type ) 377 377 clean_page_cache($post_id); -
wp-includes/taxonomy.php
1191 1191 } else { 1192 1192 // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. 1193 1193 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; 1194 $wpdb-> query( $wpdb->prepare( "UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $alias->term_id) );1194 $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); 1195 1195 } 1196 1196 } 1197 1197 -
wp-includes/user.php
189 189 } 190 190 191 191 $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 192 if ( !$cur ) { 193 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value ) 194 VALUES 195 ( %d, %s, %s )", $user_id, $meta_key, $meta_value) ); 196 } else if ( $cur->meta_value != $meta_value ) { 197 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->usermeta SET meta_value = %s WHERE user_id = %d AND meta_key = %s", $meta_value, $user_id, $meta_key) ); 198 } else { 192 if ( !$cur ) 193 $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); 194 else if ( $cur->meta_value != $meta_value ) 195 $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); 196 else 199 197 return false; 200 }201 198 202 199 wp_cache_delete($user_id, 'users'); 203 200 -
wp-login.php
131 131 $key = wp_generate_password(20, false); 132 132 do_action('retrieve_password_key', $user_login, $key); 133 133 // Now insert the new md5 key into the db 134 $wpdb-> query($wpdb->prepare("UPDATE $wpdb->users SET user_activation_key = %s WHERE user_login = %s", $key,$user_login));134 $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); 135 135 } 136 136 $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; 137 137 $message .= get_option('siteurl') . "\r\n\r\n"; -
xmlrpc.php
1436 1436 if( is_array( $attachments ) ) { 1437 1437 foreach( $attachments as $file ) { 1438 1438 if( strpos( $post_content, $file->guid ) !== false ) { 1439 $wpdb-> query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", $post_ID,$file->ID) );1439 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); 1440 1440 } 1441 1441 } 1442 1442 }