WordPress.org

Make WordPress Core

Ticket #18948: 18948.6.diff

File 18948.6.diff, 14.1 KB (added by scribu, 3 years ago)
  • wp-admin/includes/bookmark.php

    diff --git wp-admin/includes/bookmark.php wp-admin/includes/bookmark.php
    index b3a5185..3dcb602 100644
    function wp_delete_link( $link_id ) { 
    8383 
    8484        wp_delete_object_term_relationships( $link_id, 'link_category' ); 
    8585 
    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 ) ); 
    8787 
    8888        do_action( 'deleted_link', $link_id ); 
    8989 
  • wp-admin/includes/ms.php

    diff --git wp-admin/includes/ms.php wp-admin/includes/ms.php
    index 8d9a673..aaf741d 100644
    function wpmu_delete_blog( $blog_id, $drop = false ) { 
    8989                        $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); 
    9090                } 
    9191 
    92                 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); 
     92                $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) ); 
     93 
    9394                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); 
    9495                $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); 
    9596                $top_dir = $dir; 
    function wpmu_delete_user( $id ) { 
    158159                } 
    159160        } 
    160161 
    161         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id ) ); 
    162         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); 
     162        $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); 
     163        $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id ) ); 
    163164 
    164165        clean_user_cache( $id ); 
    165166 
  • wp-admin/includes/upgrade.php

    diff --git wp-admin/includes/upgrade.php wp-admin/includes/upgrade.php
    index 50c5da2..efa0ac2 100644
    As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to d 
    302302 
    303303                // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. 
    304304                if ( !is_super_admin( $user_id ) && $user_id != 1 ) 
    305                         $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') ); 
     305                        $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); 
    306306        } 
    307307} 
    308308endif; 
  • wp-admin/includes/user.php

    diff --git wp-admin/includes/user.php wp-admin/includes/user.php
    index e915fa8..63384fb 100644
    function wp_delete_user( $id, $reassign = 'novalue' ) { 
    266266 
    267267        // FINALLY, delete user 
    268268        if ( !is_multisite() ) { 
    269                 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) ); 
    270                 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) ); 
     269                $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id ) ); 
     270                $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); 
    271271        } else { 
    272272                $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels 
    273                 $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$level_key}'"); 
     273                $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id , 'meta_key' => $level_key ) ); 
    274274        } 
    275275 
    276276        // allow for commit transaction 
  • wp-includes/comment.php

    diff --git wp-includes/comment.php wp-includes/comment.php
    index dd4179c..fb7a6a2 100644
    function update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = 
    569569        return update_metadata('comment', $comment_id, $meta_key, $meta_value, $prev_value); 
    570570} 
    571571 
    572 /**   
    573  * Sets the cookies used to store an unauthenticated commentator's identity. Typically used   
    574  * to recall previous comments by this commentator that are still held in moderation.   
    575  *   
     572/** 
     573 * Sets the cookies used to store an unauthenticated commentator's identity. Typically used 
     574 * to recall previous comments by this commentator that are still held in moderation. 
     575 * 
    576576 * @param object $comment Comment object. 
    577577 * @param object $user Comment author's object. 
    578578 * 
    579579 * @since 3.4.0 
    580  */   
    581 function wp_set_comment_cookies($comment, $user) {   
     580 */ 
     581function wp_set_comment_cookies($comment, $user) { 
    582582        if ( $user->ID ) 
    583583                return; 
    584584 
    function wp_set_comment_cookies($comment, $user) { 
    586586        setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); 
    587587        setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); 
    588588        setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN); 
    589 }   
     589} 
    590590 
    591591/** 
    592592 * Sanitizes the cookies sent to the user already. 
    function wp_delete_comment($comment_id, $force_delete = false) { 
    988988                do_action( 'deleted_commentmeta', $meta_ids ); 
    989989        } 
    990990 
    991         if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) ) 
     991        if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) 
    992992                return false; 
    993993        do_action('deleted_comment', $comment_id); 
    994994 
  • wp-includes/meta.php

    diff --git wp-includes/meta.php wp-includes/meta.php
    index 3caa808..57ba347 100644
    function delete_metadata_by_mid( $meta_type, $meta_id ) { 
    489489                        do_action( 'delete_postmeta', $meta_id ); 
    490490 
    491491                // 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(), 1 ); 
    493493 
    494494                // Clear the caches. 
    495495                wp_cache_delete($object_id, $meta_type . '_meta'); 
  • wp-includes/ms-functions.php

    diff --git wp-includes/ms-functions.php wp-includes/ms-functions.php
    index 34d3310..198181b 100644
    function wpmu_validate_user_signup($user_name, $user_email) { 
    498498                $diff = $now - $registered_at; 
    499499                // If registered more than two days ago, cancel registration and let this signup go through. 
    500500                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 ) ); 
    502502                else 
    503503                        $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); 
    504504 
    function wpmu_validate_user_signup($user_name, $user_email) { 
    511511                $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); 
    512512                // If registered more than two days ago, cancel registration and let this signup go through. 
    513513                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 ) ); 
    515515                else 
    516516                        $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.')); 
    517517        } 
    function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') { 
    614614                $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered); 
    615615                // If registered more than two days ago, cancel registration and let this signup go through. 
    616616                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 ) ); 
    618618                else 
    619619                        $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.')); 
    620620        } 
    function install_blog($blog_id, $blog_title = '') { 
    11611161        $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') ); 
    11621162 
    11631163        // 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' ) ); 
     1165 
     1166        $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) ); 
    11661167 
    11671168        $wpdb->suppress_errors( false ); 
    11681169} 
  • wp-includes/option.php

    diff --git wp-includes/option.php wp-includes/option.php
    index 9e4fe15..2a25a27 100644
    function delete_option( $option ) { 
    367367        if ( is_null( $row ) ) 
    368368                return false; 
    369369        do_action( 'delete_option', $option ); 
    370         $result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = %s", $option) ); 
     370        $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) ); 
    371371        if ( ! defined( 'WP_INSTALLING' ) ) { 
    372372                if ( 'yes' == $row->autoload ) { 
    373373                        $alloptions = wp_load_alloptions(); 
    function delete_site_option( $option ) { 
    857857                $cache_key = "{$wpdb->siteid}:$option"; 
    858858                wp_cache_delete( $cache_key, 'site-options' ); 
    859859 
    860                 $result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ); 
     860                $result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $wpdb->siteid ) ); 
    861861        } 
    862862 
    863863        if ( $result ) { 
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 2bdd51b..bad835a 100644
    function wp_delete_post( $postid = 0, $force_delete = false ) { 
    20372037        } 
    20382038 
    20392039        do_action( 'delete_post', $postid ); 
    2040         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid )); 
     2040        $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); 
    20412041        do_action( 'deleted_post', $postid ); 
    20422042 
    20432043        if ( 'page' == $post->post_type ) { 
    function wp_delete_attachment( $post_id, $force_delete = false ) { 
    37893789        wp_delete_object_term_relationships($post_id, array('category', 'post_tag')); 
    37903790        wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type)); 
    37913791 
    3792         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $post_id )); 
     3792        $wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_thumbnail_id' , 'meta_value' => $post_id ) ); 
    37933793 
    37943794        $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id )); 
    37953795        if ( ! empty( $comment_ids ) ) { 
    function wp_delete_attachment( $post_id, $force_delete = false ) { 
    38083808        } 
    38093809 
    38103810        do_action( 'delete_post', $post_id ); 
    3811         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id )); 
     3811        $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); 
    38123812        do_action( 'deleted_post', $post_id ); 
    38133813 
    38143814        $uploadpath = wp_upload_dir(); 
  • wp-includes/taxonomy.php

    diff --git wp-includes/taxonomy.php wp-includes/taxonomy.php
    index 5f377f6..796dddb 100644
    function wp_delete_term( $term, $taxonomy, $args = array() ) { 
    18031803                clean_object_term_cache( $objects, $object_type ); 
    18041804 
    18051805        do_action( 'delete_term_taxonomy', $tt_id ); 
    1806         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $tt_id ) ); 
     1806        $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) ); 
    18071807        do_action( 'deleted_term_taxonomy', $tt_id ); 
    18081808 
    18091809        // Delete the term if no taxonomies use it. 
    18101810        if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) ) 
    1811                 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) ); 
     1811                $wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) ); 
    18121812 
    18131813        clean_term_cache($term, $taxonomy); 
    18141814 
  • wp-includes/wp-db.php

    diff --git wp-includes/wp-db.php wp-includes/wp-db.php
    index 2347c91..c80f9b0 100644
    class wpdb { 
    404404         * Keys are column names, values are format types: 'ID' => '%d' 
    405405         * 
    406406         * @since 2.8.0 
    407          * @see wpdb:prepare() 
    408          * @see wpdb:insert() 
    409          * @see wpdb:update() 
     407         * @see wpdb::prepare() 
     408         * @see wpdb::insert() 
     409         * @see wpdb::update() 
     410         * @see wpdb::delete() 
    410411         * @see wp_set_wpdb_vars() 
    411412         * @access public 
    412413         * @var array 
    class wpdb { 
    12721273        } 
    12731274 
    12741275        /** 
     1276         * Delete a row in the table 
     1277         * 
     1278         * <code> 
     1279         * wpdb::delete( 'table', array( 'ID' => 1 ) ) 
     1280         * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) ) 
     1281         * wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ), 1 ) 
     1282         * </code> 
     1283         * 
     1284         * @since 2.5.0 
     1285         * @see wpdb::prepare() 
     1286         * @see wpdb::$field_types 
     1287         * @see wp_set_wpdb_vars() 
     1288         * 
     1289         * @param string $table table name 
     1290         * @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". 
     1291         * @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 unless otherwise specified in wpdb::$field_types. 
     1292         * @param int $limit Optional. An int to limit the number of rows to delete. 
     1293         * @return int|false The number of rows updated, or false on error. 
     1294         */ 
     1295        function delete( $table, $where, $where_format = null, $limit = null ) { 
     1296                if ( ! is_array( $where ) ) 
     1297                        return false; 
     1298 
     1299                $bits = $wheres = array(); 
     1300 
     1301                $where_formats = $where_format = (array) $where_format; 
     1302 
     1303                foreach ( array_keys( $where ) as $field ) { 
     1304                        if ( !empty( $where_format ) ) { 
     1305                                $form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0]; 
     1306                        } elseif ( isset( $this->field_types[$field] ) ) { 
     1307                                $form = $this->field_types[$field]; 
     1308                        } else { 
     1309                                $form = '%s'; 
     1310                        } 
     1311 
     1312                        $wheres[] = "$field = $form"; 
     1313                } 
     1314 
     1315                $limits = ''; 
     1316                if ( !empty( $limit ) ) { 
     1317                        $limits = ' LIMIT ' . (int) $limit; 
     1318                } 
     1319 
     1320                $sql = "DELETE FROM $table WHERE " . implode( ' AND ', $wheres ) . $limits; 
     1321                return $this->query( $this->prepare( $sql, $where ) ); 
     1322        } 
     1323 
     1324 
     1325        /** 
    12751326         * Retrieve one variable from the database. 
    12761327         * 
    12771328         * Executes a SQL query and returns the value from the SQL result.