]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/upgrade.php
WordPress 4.2.3
[autoinstalls/wordpress.git] / wp-admin / includes / upgrade.php
index 495d5b437dc5a7ef28f5ab209cc99b3c6e3d3ec3..cb2188b4ab25b4e74a5bbba58ce2e15f10239158 100644 (file)
@@ -524,14 +524,11 @@ function upgrade_all() {
        if ( $wp_current_db_version < 29630 )
                upgrade_400();
 
        if ( $wp_current_db_version < 29630 )
                upgrade_400();
 
-       // Don't harsh my mellow. upgrade_422() must be called before
-       // upgrade_420() to catch bad comments prior to any auto-expansion of
-       // MySQL column widths.
        if ( $wp_current_db_version < 31534 )
                upgrade_422();
 
        if ( $wp_current_db_version < 31534 )
                upgrade_422();
 
-       if ( $wp_current_db_version < 31351 )
-               upgrade_420();
+       if ( $wp_current_db_version < 31536 )
+               upgrade_423();
 
        maybe_disable_link_manager();
 
 
        maybe_disable_link_manager();
 
@@ -1426,19 +1423,6 @@ function upgrade_400() {
  * @since 4.2.0
  */
 function upgrade_420() {
  * @since 4.2.0
  */
 function upgrade_420() {
-       global $wp_current_db_version, $wpdb;
-
-       if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
-               if ( is_multisite() ) {
-                       $tables = $wpdb->tables( 'blog' );
-               } else {
-                       $tables = $wpdb->tables( 'all' );
-               }
-
-               foreach ( $tables as $table ) {
-                       maybe_convert_table_to_utf8mb4( $table );
-               }
-       }
 }
 
 /**
 }
 
 /**
@@ -1497,6 +1481,31 @@ function upgrade_422() {
        }
 }
 
        }
 }
 
+/**
+ * Execute changes made in WordPress 4.2.0.
+ *
+ * @since 4.2.3
+ */
+function upgrade_423() {
+       global $wp_current_db_version, $wpdb;
+
+       if ( $wp_current_db_version < 31536 && $wpdb->charset === 'utf8mb4' ) {
+               if ( is_multisite() ) {
+                       $tables = $wpdb->tables( 'blog' );
+               } else {
+                       $tables = $wpdb->tables( 'all' );
+                       if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
+                               $global_tables = $wpdb->tables( 'global' );
+                               $tables = array_diff_assoc( $tables, $global_tables );
+                       }
+               }
+
+               foreach ( $tables as $table ) {
+                       maybe_convert_table_to_utf8mb4( $table );
+               }
+       }
+}
+
 /**
  * Executes network-level upgrade routines.
  *
 /**
  * Executes network-level upgrade routines.
  *
@@ -1596,7 +1605,7 @@ function upgrade_network() {
 
        // 4.2
        if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
 
        // 4.2
        if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
-               if ( ! ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) && DO_NOT_UPGRADE_GLOBAL_TABLES ) ) {
+               if ( ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
                        $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
                        $wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
                        $wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
                        $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
                        $wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
                        $wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
@@ -1612,7 +1621,7 @@ function upgrade_network() {
 
        // 4.2.2
        if ( $wp_current_db_version < 31535 && 'utf8mb4' === $wpdb->charset ) {
 
        // 4.2.2
        if ( $wp_current_db_version < 31535 && 'utf8mb4' === $wpdb->charset ) {
-               if ( ! ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) && DO_NOT_UPGRADE_GLOBAL_TABLES ) ) {
+               if ( ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
                        $upgrade = false;
                        $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
                        foreach( $indexes as $index ) {
                        $upgrade = false;
                        $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
                        foreach( $indexes as $index ) {
@@ -1627,6 +1636,17 @@ function upgrade_network() {
                        }
                }
        }
                        }
                }
        }
+
+       // 4.2.3
+       if ( $wp_current_db_version < 31536 && $wpdb->charset === 'utf8mb4' ) {
+               if ( ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
+                       $tables = $wpdb->tables( 'global' );
+
+                       foreach ( $tables as $table ) {
+                               maybe_convert_table_to_utf8mb4( $table );
+                       }
+               }
+       }
 }
 
 //
 }
 
 //
@@ -1759,6 +1779,17 @@ function maybe_convert_table_to_utf8mb4( $table ) {
                }
        }
 
                }
        }
 
+       $table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" );
+       if ( ! $table_details ) {
+               return false;
+       }
+
+       list( $table_charset ) = explode( '_', $table_details->Collation );
+       $table_charset = strtolower( $table_charset );
+       if ( 'utf8mb4' === $table_charset ) {
+               return true;
+       }
+
        return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
 }
 
        return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
 }
 
@@ -2446,14 +2477,9 @@ function pre_schema_upgrade() {
                }
        }
 
                }
        }
 
-       if ( $wp_current_db_version < 30133 ) {
-               // dbDelta() can recreate but can't drop the index.
-               $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug" );
-       }
-
        // Upgrade versions prior to 4.2.
        if ( $wp_current_db_version < 31351 ) {
        // Upgrade versions prior to 4.2.
        if ( $wp_current_db_version < 31351 ) {
-               if ( ! is_multisite() ) {
+               if ( ! is_multisite() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
                        $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
                }
                $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
                        $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
                }
                $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );