WordPress.org

Make WordPress Core

Ticket #12028: 12028.diff

File 12028.diff, 2.6 KB (added by ryan, 7 years ago)
  • wp-admin/includes/upgrade.php

     
    14241424 * @param unknown_type $execute
    14251425 * @return unknown
    14261426 */
    1427 function dbDelta($queries, $execute = true) {
     1427function dbDelta($queries = '', $execute = true) {
    14281428        global $wpdb;
    14291429
     1430        if ( empty( $queries ) )
     1431                $queries = get_create_table_sql();
     1432
    14301433        // Separate individual queries into an array
    14311434        if ( !is_array($queries) ) {
    14321435                $queries = explode( ';', $queries );
     
    16321635 * @since 1.5.0
    16331636 */
    16341637function make_db_current() {
    1635         global $wp_queries;
    1636 
    1637         $alterations = dbDelta($wp_queries);
     1638        $alterations = dbDelta();
    16381639        echo "<ol>\n";
    16391640        foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
    16401641        echo "</ol>\n";
     
    16481649 * @since 1.5.0
    16491650 */
    16501651function make_db_current_silent() {
    1651         global $wp_queries;
    1652 
    1653         $alterations = dbDelta($wp_queries);
     1652        $alterations = dbDelta();
    16541653}
    16551654
    16561655/**
  • wp-admin/includes/schema.php

     
    88 * @subpackage Administration
    99 */
    1010
    11 /**
    12  * The database character collate.
    13  * @var string
    14  * @global string
    15  * @name $charset_collate
    16  */
    17 $charset_collate = '';
    18 
    1911// Declare these as global in case schema.php is included from a function.
    2012global $wpdb, $wp_queries;
    2113
    22 if ( ! empty($wpdb->charset) )
    23         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    24 if ( ! empty($wpdb->collate) )
    25         $charset_collate .= " COLLATE $wpdb->collate";
     14/** Create WordPress database tables SQL */
     15function get_create_table_sql( $blog_id = null ) {
     16        global $wpdb;
    2617
    27 /** Create WordPress database tables SQL */
    28 $wp_queries = "CREATE TABLE $wpdb->terms (
     18        if ( ! empty($wpdb->charset) )
     19                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     20        if ( ! empty($wpdb->collate) )
     21                $charset_collate .= " COLLATE $wpdb->collate";
     22
     23        if ( $blog_id && $blog_id != $wpdb->blogid )
     24                $old_blog_id = $wpdb->set_blog_id( $blog_id );
     25
     26        $queries = "CREATE TABLE $wpdb->terms (
    2927 term_id bigint(20) unsigned NOT NULL auto_increment,
    3028 name varchar(200) NOT NULL default '',
    3129 slug varchar(200) NOT NULL default '',
     
    174172  KEY meta_key (meta_key)
    175173) $charset_collate;";
    176174
     175        if ( isset( $old_blog_id ) )
     176                $wpdb->set_blog_id( $old_blog_id );
     177
     178        return $queries;
     179}
     180
     181$wp_queries = get_create_table_sql();
     182
    177183/**
    178184 * Create WordPress options and set the default values.
    179185 *