Ticket #18948: 18948.2.diff
File 18948.2.diff, 14.7 KB (added by , 13 years ago) |
---|
-
wp-includes/taxonomy.php
1765 1765 clean_object_term_cache( $objects, $object_type ); 1766 1766 1767 1767 do_action( 'delete_term_taxonomy', $tt_id ); 1768 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $tt_id) );1768 $wpdb->delete( "$wpdb->term_taxonomy" , array( "term_taxonomy_id" => $tt_id ) , array( '%d' ) ); 1769 1769 do_action( 'deleted_term_taxonomy', $tt_id ); 1770 1770 1771 1771 // Delete the term if no taxonomies use it. 1772 1772 if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) ) 1773 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) );1773 $wpdb->delete( "$wpdb->terms" , array( "term_id" => $term ) , array( '%d' ) ); 1774 1774 1775 1775 clean_term_cache($term, $taxonomy); 1776 1776 -
wp-includes/post.php
2031 2031 } 2032 2032 2033 2033 do_action( 'delete_post', $postid ); 2034 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));2034 $wpdb->delete( "$wpdb->posts" , array( "ID" => $postid ) , array( '%d' ) ); 2035 2035 do_action( 'deleted_post', $postid ); 2036 2036 2037 2037 if ( 'page' == $post->post_type ) { … … 3783 3783 wp_delete_object_term_relationships($post_id, array('category', 'post_tag')); 3784 3784 wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type)); 3785 3785 3786 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $post_id ));3786 $wpdb->delete( "$wpdb->postmeta" , array( "meta_key" => '_thumbnail_id' , "meta_value" => $post_id ) , array( '%s' , '%d' ) ); 3787 3787 3788 3788 $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id )); 3789 3789 if ( ! empty( $comment_ids ) ) { … … 3802 3802 } 3803 3803 3804 3804 do_action( 'delete_post', $post_id ); 3805 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));3805 $wpdb->delete( "$wpdb->posts" , array( "ID" => $post_id ) , array( '%d' ) ); 3806 3806 do_action( 'deleted_post', $post_id ); 3807 3807 3808 3808 $uploadpath = wp_upload_dir(); -
wp-includes/comment.php
970 970 do_action( 'deleted_commentmeta', $meta_ids ); 971 971 } 972 972 973 if ( ! $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ))973 if ( ! $wpdb->delete( "$wpdb->comments" , array( "comment_ID" => $comment_id ) , array( '%d' ) , 1 ); ) 974 974 return false; 975 975 do_action('deleted_comment', $comment_id); 976 976 -
wp-includes/functions.php
665 665 if ( is_null( $row ) ) 666 666 return false; 667 667 do_action( 'delete_option', $option ); 668 $result = $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = %s", $option) );668 $result = $wpdb->delete( "$wpdb->options" , array( "option_name" => $option) , array( '%s' ) ); 669 669 if ( ! defined( 'WP_INSTALLING' ) ) { 670 670 if ( 'yes' == $row->autoload ) { 671 671 $alloptions = wp_load_alloptions(); … … 3890 3890 $cache_key = "{$wpdb->siteid}:$option"; 3891 3891 wp_cache_delete( $cache_key, 'site-options' ); 3892 3892 3893 $result = $wpdb-> query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid) );3893 $result = $wpdb->delete( "{$wpdb->sitemeta}" , array( "meta_key" => $option , "site_id" => $wpdb->siteid ) , array( '%s' , '%d' ) ); 3894 3894 } 3895 3895 3896 3896 if ( $result ) { -
wp-includes/wp-db.php
409 409 * @see wpdb:prepare() 410 410 * @see wpdb:insert() 411 411 * @see wpdb:update() 412 * @see wpdb:delete() 412 413 * @see wp_set_wpdb_vars() 413 414 * @access public 414 415 * @var array … … 1252 1253 $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ); 1253 1254 return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) ); 1254 1255 } 1256 1257 /** 1258 * Delete a row in the table 1259 * 1260 * <code> 1261 * wpdb::delete( 'table', array( 'ID' => 1 ) ) 1262 * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) ) 1263 * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ), 1 ) 1264 * </code> 1265 * 1266 * @since 2.5.0 1267 * @see wpdb::prepare() 1268 * @see wpdb::$field_types 1269 * @see wp_set_wpdb_vars() 1270 * 1271 * @param string $table table name 1272 * @param array $where A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw". 1273 * @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of '%d', '%f', '%s' (integer, float, string). If omitted, all values in $where will be treated as strings. 1274 * A format is one of '%d', '%f', '%s' (integer, float, string). If omitted, all values in $where will be treated as strings unless otherwise specified in wpdb::$field_types. 1275 * @param int $limit to number of rows to delete. 1276 * @return int|false The number of rows updated, or false on error. 1277 */ 1278 function delete( $table, $where, $where_format = null, $limit = null) { 1279 if ( ! is_array( $where ) ) 1280 return false; 1281 1282 $bits = $wheres = array(); 1255 1283 1284 $where_formats = $where_format = (array) $where_format; 1285 foreach ( (array) array_keys( $where ) as $field ) { 1286 if ( !empty( $where_format ) ) 1287 $form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0]; 1288 elseif ( isset( $this->field_types[$field] ) ) 1289 $form = $this->field_types[$field]; 1290 else 1291 $form = '%s'; 1292 $wheres[] = "`$field` = {$form}"; 1293 } 1294 $limits = ''; 1295 if (!empty($limit) { 1296 if (is_int($limit)) 1297 $limits = ' LIMIT ' . $limit; 1298 } 1299 1300 $sql = "DELETE FROM `$table` WHERE " . implode( ' AND ', $wheres ) . $limits; 1301 return $this->query( $this->prepare( $sql, $where ) ); 1302 } 1303 1304 1256 1305 /** 1257 1306 * Retrieve one variable from the database. 1258 1307 * -
wp-includes/deprecated.php
2292 2292 do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 2293 2293 2294 2294 if ( ! empty($meta_value) ) 2295 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) );2295 $wpdb->delete( "$wpdb->usermeta" , array( "user_id" => $user_id , "meta_key" => $meta_key , "meta_value" => $meta_value ) , array( '%d' , '%s' , '%s' ) ); 2296 2296 else 2297 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );2297 $wpdb->delete( "$wpdb->usermeta" , array( "user_id" => $user_id , "meta_key" => $meta_key ) , array( '%d' , '%s' ) ); 2298 2298 2299 2299 clean_user_cache( $user_id ); 2300 2300 wp_cache_delete( $user_id, 'user_meta' ); -
wp-includes/ms-functions.php
498 498 $diff = $now - $registered_at; 499 499 // If registered more than two days ago, cancel registration and let this signup go through. 500 500 if ( $diff > 172800 ) 501 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_login = %s", $user_name) );501 $wpdb->delete( "$wpdb->signups" , array( "user_login" => $user_name ) , array( '%s' ) ); 502 502 else 503 503 $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); 504 504 … … 511 511 $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); 512 512 // If registered more than two days ago, cancel registration and let this signup go through. 513 513 if ( $diff > 172800 ) 514 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_email = %s", $user_email) );514 $wpdb->delete( "$wpdb->signups" , array( "user_email" => $user_email ) , array( '%s' ) ); 515 515 else 516 516 $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); 517 517 } … … 614 614 $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); 615 615 // If registered more than two days ago, cancel registration and let this signup go through. 616 616 if ( $diff > 172800 ) 617 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) );617 $wpdb->delete( "$wpdb->signups" , array( "domain" => $mydomain , "path" => $path ) , array( '%s' , '%s' ) ); 618 618 else 619 619 $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); 620 620 } … … 1161 1161 $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') ); 1162 1162 1163 1163 // remove all perms 1164 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'user_level') ); 1165 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'capabilities') ); 1164 $wpdb->delete( "$wpdb->usermeta" , array( "meta_key" => $table_prefix.'user_level' ) , array( '%s' ) ); 1165 1166 $wpdb->delete( "$wpdb->usermeta" , array( "meta_key" => $table_prefix.'capabilities' ) , array( '%s' ) ); 1166 1167 1167 1168 $wpdb->suppress_errors( false ); 1168 1169 } -
wp-includes/meta.php
489 489 do_action( 'delete_postmeta', $meta_id ); 490 490 491 491 // Run the query, will return true if deleted, false otherwise 492 $result = (bool) $wpdb-> query( $wpdb->prepare( "DELETE FROM $table WHERE $id_column = %d LIMIT 1;", $meta_id ));492 $result = (bool) $wpdb->delete( "$table" , array( "$id_column" => $meta_id ) , array( '%d' ) , 1 ); 493 493 494 494 // Clear the caches. 495 495 wp_cache_delete($object_id, $meta_type . '_meta'); -
wp-admin/includes/bookmark.php
83 83 84 84 wp_delete_object_term_relationships( $link_id, 'link_category' ); 85 85 86 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->links WHERE link_id = %d", $link_id) );86 $wpdb->delete( "$wpdb->links" , array( 'link_id' => $link_id ) , array ( '%d' ) ); 87 87 88 88 do_action( 'deleted_link', $link_id ); 89 89 -
wp-admin/includes/upgrade.php
297 297 298 298 // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. 299 299 if ( !is_super_admin( $user_id ) && $user_id != 1 ) 300 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );300 $wpdb->delete( "$wpdb->usermeta" , array( "user_id" => $user_id , "meta_key" => $wpdb->base_prefix.'1_capabilities' ) , array( '%d' , '%s' ) ); 301 301 } 302 302 } 303 303 endif; -
wp-admin/includes/schema.php
513 513 delete_option($option); 514 514 515 515 // delete obsolete magpie stuff 516 $wpdb-> query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");516 $wpdb->delete( "$wpdb->options" , array( 'option_name' => "REGEXP '^rss_[0-9a-f]{32}(_ts)?$'" ) , array( '%s' ) ); 517 517 } 518 518 519 519 /** -
wp-admin/includes/user.php
292 292 293 293 // FINALLY, delete user 294 294 if ( !is_multisite() ) { 295 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );296 $wpdb-> query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );295 $wpdb->delete( "$wpdb->usermeta" , array( "user_id" => $id ) , array( '%d' ) ); 296 $wpdb->delete( "$wpdb->users" , array( "ID" => $id ) , array( '%d' ) ); 297 297 } else { 298 298 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels 299 $wpdb-> query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$level_key}'");299 $wpdb->delete( "$wpdb->usermeta" , array( "user_id" => $id , "meta_key" => "'{$level_key}'" ) , array( '%d' , '%s' ) ); 300 300 } 301 301 302 302 // allow for commit transaction -
wp-admin/includes/ms.php
87 87 foreach ( (array) $drop_tables as $drop_table) { 88 88 $wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" ); 89 89 } 90 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id) );90 $wpdb->delete( "$wpdb->blogs" , array( "blog_id" => $blog_id ) , array( '%d' ) ); 91 91 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); 92 92 $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); 93 93 $top_dir = $dir; … … 120 120 } 121 121 } 122 122 123 $wpdb-> query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'");123 $wpdb->delete( "{$wpdb->usermeta}" , array( "meta_key" => "'{$blog_prefix}autosave_draft_ids'" ) , array( '%s' ) ); 124 124 $blogs = get_site_option( 'blog_list' ); 125 125 if ( is_array( $blogs ) ) { 126 126 foreach ( $blogs as $n => $blog ) { … … 166 166 } 167 167 } 168 168 169 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id) );170 $wpdb-> query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );169 $wpdb->delete( "$wpdb->users" , array( "ID" => $id ) , array( '%d' ) ); 170 $wpdb->delete( "$wpdb->usermeta" , array( "user_id" => $id ) , array( '%d' ) ); 171 171 172 172 clean_user_cache( $id ); 173 173