Make WordPress Core

Ticket #7171: 7171.2.diff

File 7171.2.diff, 3.7 KB (added by mdawaffe, 16 years ago)

move $db_field_types to $wpdb->field_types

  • wp-includes/wp-db.php

     
    255255                        'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
    256256
    257257        /**
     258         * Format specifiers for DB columns. Columns not listed here default to %s.  Initialized in wp-settings.php.
     259         *
     260         * Keys are colmn names, values are format types: 'ID' => '%d'
     261         *
     262         * @since 2.8.0
     263         * @see wpdb:prepare()
     264         * @see wpdb:insert()
     265         * @see wpdb:update()
     266         * @access public
     267         * @war array
     268         */
     269        var $field_type = array();
     270
     271        /**
    258272         * Database table columns charset
    259273         *
    260274         * @since 2.2.0
     
    703717         * @return mixed Results of $this->query()
    704718         */
    705719        function insert($table, $data, $format = null) {
    706                 global $db_field_types;
    707 
    708720                $formats = $format = (array) $format;
    709721                $fields = array_keys($data);
    710722                $formatted_fields = array();
    711723                foreach ( $fields as $field ) {
    712724                        if ( !empty($format) )
    713725                                $form = ( $form = array_shift($formats) ) ? $form : $format[0];
    714                         elseif ( isset($db_field_types[$field]) )
    715                                 $form = $db_field_types[$field];
     726                        elseif ( isset($this->field_types[$field]) )
     727                                $form = $this->field_types[$field];
    716728                        else
    717729                                $form = '%s';
    718730                        $formatted_fields[] = $form;
     
    734746         * @return mixed Results of $this->query()
    735747         */
    736748        function update($table, $data, $where, $format = null, $where_format = null) {
    737                 global $db_field_types;
    738 
    739749                if ( !is_array( $where ) )
    740750                        return false;
    741751
     
    744754                foreach ( (array) array_keys($data) as $field ) {
    745755                        if ( !empty($format) )
    746756                                $form = ( $form = array_shift($formats) ) ? $form : $format[0];
    747                         elseif ( isset($db_field_types[$field]) )
    748                                 $form = $db_field_types[$field];
     757                        elseif ( isset($this->field_types[$field]) )
     758                                $form = $this->field_types[$field];
    749759                        else
    750760                                $form = '%s';
    751761                        $bits[] = "`$field` = {$form}";
     
    755765                foreach ( (array) array_keys($where) as $field ) {
    756766                        if ( !empty($where_format) )
    757767                                $form = ( $form = array_shift($where_formats) ) ? $form : $where_format[0];
    758                         elseif ( isset($db_field_types[$field]) )
    759                                 $form = $db_field_types[$field];
     768                        elseif ( isset($this->field_types[$field]) )
     769                                $form = $this->field_types[$field];
    760770                        else
    761771                                $form = '%s';
    762772                        $wheres[] = "$field = {$form}";
  • wp-settings.php

     
    247247require (ABSPATH . WPINC . '/functions.php');
    248248require (ABSPATH . WPINC . '/classes.php');
    249249
     250require_wp_db();
     251
     252if ( !empty($wpdb->error) )
     253        dead_db();
     254
    250255/**
    251256 * Format specifiers for DB columns. Columns not listed here default to %s.
    252257 * @since 2.8.0
     258 * @see wpdb:$field_types
     259 * @see wpdb:prepare()
     260 * @see wpdb:insert()
     261 * @see wpdb:update()
    253262 */
    254 $db_field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
     263$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
    255264        'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
    256265        'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
    257266        'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
    258267
    259 require_wp_db();
    260 
    261 if ( !empty($wpdb->error) )
    262         dead_db();
    263 
    264268$prefix = $wpdb->set_prefix($table_prefix);
    265269
    266270if ( is_wp_error($prefix) )