~canonical-sysadmins/wordpress/4.7.1

« back to all changes in this revision

Viewing changes to wp-admin/includes/upgrade.php

  • Committer: Paul Gear
  • Date: 2015-04-24 01:35:20 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: paul.gear@canonical.com-20150424013520-w4p9ksth76zh6opw
Merge new upstream release 4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/**
3
3
 * WordPress Upgrade API
4
4
 *
5
 
 * Most of the functions are pluggable and can be overwritten
 
5
 * Most of the functions are pluggable and can be overwritten.
6
6
 *
7
7
 * @package WordPress
8
8
 * @subpackage Administration
20
20
 
21
21
if ( !function_exists('wp_install') ) :
22
22
/**
23
 
 * Installs the blog
 
23
 * Installs the site.
24
24
 *
25
 
 * {@internal Missing Long Description}}
 
25
 * Runs the required functions to set up and populate the database,
 
26
 * including primary admin user and initial options.
26
27
 *
27
28
 * @since 2.1.0
28
29
 *
29
 
 * @param string $blog_title Blog title.
30
 
 * @param string $user_name User's username.
31
 
 * @param string $user_email User's email.
32
 
 * @param bool $public Whether blog is public.
33
 
 * @param string $deprecated Optional. Not used.
34
 
 * @param string $user_password Optional. User's chosen password. Will default to a random password.
35
 
 * @param string $language Optional. Language chosen.
36
 
 * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
 
30
 * @param string $blog_title    Blog title.
 
31
 * @param string $user_name     User's username.
 
32
 * @param string $user_email    User's email.
 
33
 * @param bool   $public        Whether blog is public.
 
34
 * @param string $deprecated    Optional. Not used.
 
35
 * @param string $user_password Optional. User's chosen password. Default empty (random password).
 
36
 * @param string $language      Optional. Language chosen. Default empty.
 
37
 * @return array Array keys 'url', 'user_id', 'password', and 'password_message'.
37
38
 */
38
39
function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
39
40
        if ( !empty( $deprecated ) )
74
75
                $user_id = wp_create_user($user_name, $user_password, $user_email);
75
76
                update_user_option($user_id, 'default_password_nag', true, true);
76
77
                $email_password = true;
77
 
        } else if ( !$user_id ) {
 
78
        } elseif ( ! $user_id ) {
78
79
                // Password has been provided
79
80
                $message = '<em>'.__('Your chosen password.').'</em>';
80
81
                $user_id = wp_create_user($user_name, $user_password, $user_email);
87
88
 
88
89
        wp_install_defaults($user_id);
89
90
 
 
91
        wp_install_maybe_enable_pretty_permalinks();
 
92
 
90
93
        flush_rewrite_rules();
91
94
 
92
95
        wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
108
111
 
109
112
if ( !function_exists('wp_install_defaults') ) :
110
113
/**
111
 
 * {@internal Missing Short Description}}
 
114
 * Creates the initial content for a newly-installed site.
112
115
 *
113
 
 * {@internal Missing Long Description}}
 
116
 * Adds the default "Uncategorized" category, the first post (with comment),
 
117
 * first page, and default widgets for default theme for the current version.
114
118
 *
115
119
 * @since 2.1.0
116
120
 *
140
144
        $cat_tt_id = $wpdb->insert_id;
141
145
 
142
146
        // First post
143
 
        $now = date('Y-m-d H:i:s');
144
 
        $now_gmt = gmdate('Y-m-d H:i:s');
145
 
        $first_post_guid = get_option('home') . '/?p=1';
 
147
        $now = current_time( 'mysql' );
 
148
        $now_gmt = current_time( 'mysql', 1 );
 
149
        $first_post_guid = get_option( 'home' ) . '/?p=1';
146
150
 
147
151
        if ( is_multisite() ) {
148
152
                $first_post = get_site_option( 'first_post' );
260
264
}
261
265
endif;
262
266
 
 
267
/**
 
268
 * Maybe enable pretty permalinks on install.
 
269
 *
 
270
 * If after enabling pretty permalinks don't work, fallback to query-string permalinks.
 
271
 *
 
272
 * @since 4.2.0
 
273
 *
 
274
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 
275
 *
 
276
 * @return bool Whether pretty permalinks are enabled. False otherwise.
 
277
 */
 
278
function wp_install_maybe_enable_pretty_permalinks() {
 
279
        global $wp_rewrite;
 
280
 
 
281
        // Bail if a permalink structure is already enabled.
 
282
        if ( get_option( 'permalink_structure' ) ) {
 
283
                return true;
 
284
        }
 
285
 
 
286
        /*
 
287
         * The Permalink structures to attempt.
 
288
         *
 
289
         * The first is designed for mod_rewrite or nginx rewriting.
 
290
         *
 
291
         * The second is PATHINFO-based permalinks for web server configurations
 
292
         * without a true rewrite module enabled.
 
293
         */
 
294
        $permalink_structures = array(
 
295
                '/%year%/%monthnum%/%day%/%postname%/',
 
296
                '/index.php/%year%/%monthnum%/%day%/%postname%/'
 
297
        );
 
298
 
 
299
        foreach ( (array) $permalink_structures as $permalink_structure ) {
 
300
                $wp_rewrite->set_permalink_structure( $permalink_structure );
 
301
 
 
302
                /*
 
303
                 * Flush rules with the hard option to force refresh of the web-server's
 
304
                 * rewrite config file (e.g. .htaccess or web.config).
 
305
                 */
 
306
                $wp_rewrite->flush_rules( true );
 
307
 
 
308
                // Test against a real WordPress Post, or if none were created, a random 404 page.
 
309
                $test_url = get_permalink( 1 );
 
310
 
 
311
                if ( ! $test_url ) {
 
312
                        $test_url = home_url( '/wordpress-check-for-rewrites/' );
 
313
                }
 
314
 
 
315
                /*
 
316
                 * Send a request to the site, and check whether
 
317
                 * the 'x-pingback' header is returned as expected.
 
318
                 *
 
319
                 * Uses wp_remote_get() instead of wp_remote_head() because web servers
 
320
                 * can block head requests.
 
321
                 */
 
322
                $response          = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
 
323
                $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
 
324
                $pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
 
325
 
 
326
                if ( $pretty_permalinks ) {
 
327
                        return true;
 
328
                }
 
329
        }
 
330
 
 
331
        /*
 
332
         * If it makes it this far, pretty permalinks failed.
 
333
         * Fallback to query-string permalinks.
 
334
         */
 
335
        $wp_rewrite->set_permalink_structure( '' );
 
336
        $wp_rewrite->flush_rules( true );
 
337
 
 
338
        return false;
 
339
}
 
340
 
263
341
if ( !function_exists('wp_new_blog_notification') ) :
264
342
/**
265
 
 * {@internal Missing Short Description}}
 
343
 * Notifies the site admin that the setup is complete.
266
344
 *
267
 
 * {@internal Missing Long Description}}
 
345
 * Sends an email with wp_mail to the new administrator that the site setup is complete,
 
346
 * and provides them with a record of their login credentials.
268
347
 *
269
348
 * @since 2.1.0
270
349
 *
271
350
 * @param string $blog_title Blog title.
272
 
 * @param string $blog_url Blog url.
273
 
 * @param int $user_id User ID.
274
 
 * @param string $password User's Password.
 
351
 * @param string $blog_url   Blog url.
 
352
 * @param int    $user_id    User ID.
 
353
 * @param string $password   User's Password.
275
354
 */
276
355
function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
277
356
        $user = new WP_User( $user_id );
300
379
 
301
380
if ( !function_exists('wp_upgrade') ) :
302
381
/**
303
 
 * Run WordPress Upgrade functions.
 
382
 * Runs WordPress Upgrade functions.
304
383
 *
305
 
 * {@internal Missing Long Description}}
 
384
 * Upgrades the database if needed during a site update.
306
385
 *
307
386
 * @since 2.1.0
308
387
 *
309
 
 * @return null
 
388
 * @return null If no update is necessary or site isn't completely installed, null.
310
389
 */
311
390
function wp_upgrade() {
312
391
        global $wp_current_db_version, $wp_db_version, $wpdb;
351
430
/**
352
431
 * Functions to be called in install and upgrade scripts.
353
432
 *
354
 
 * {@internal Missing Long Description}}
 
433
 * Contains conditional checks to determine which upgrade scripts to run,
 
434
 * based on database version and WP version being updated-to.
355
435
 *
356
436
 * @since 1.0.1
 
437
 *
 
438
 * @return null If no update is necessary, null.
357
439
 */
358
440
function upgrade_all() {
359
441
        global $wp_current_db_version, $wp_db_version;
442
524
        if ( $wp_current_db_version < 29630 )
443
525
                upgrade_400();
444
526
 
 
527
        if ( $wp_current_db_version < 31351 )
 
528
                upgrade_420();
 
529
 
445
530
        maybe_disable_link_manager();
446
531
 
447
532
        maybe_disable_automattic_widgets();
485
570
 
486
571
        $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
487
572
        if ($done_ids) :
 
573
                $done_posts = array();
488
574
                foreach ($done_ids as $done_id) :
489
575
                        $done_posts[] = $done_id->post_id;
490
576
                endforeach;
769
855
                        if ( 'static' == $status ) {
770
856
                                $status = 'publish';
771
857
                                $type = 'page';
772
 
                        } else if ( 'attachment' == $status ) {
 
858
                        } elseif ( 'attachment' == $status ) {
773
859
                                $status = 'inherit';
774
860
                                $type = 'attachment';
775
861
                        }
1329
1415
}
1330
1416
 
1331
1417
/**
1332
 
 * Execute network level changes
 
1418
 * Execute changes made in WordPress 4.2.0.
 
1419
 *
 
1420
 * @since 4.2.0
 
1421
 */
 
1422
function upgrade_420() {
 
1423
        global $wp_current_db_version, $wpdb;
 
1424
 
 
1425
        if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
 
1426
                if ( is_multisite() ) {
 
1427
                        $tables = $wpdb->tables( 'blog' );
 
1428
                } else {
 
1429
                        $tables = $wpdb->tables( 'all' );
 
1430
                }
 
1431
 
 
1432
                foreach ( $tables as $table ) {
 
1433
                        maybe_convert_table_to_utf8mb4( $table );
 
1434
                }
 
1435
        }
 
1436
}
 
1437
 
 
1438
/**
 
1439
 * Executes network-level upgrade routines.
1333
1440
 *
1334
1441
 * @since 3.0.0
1335
1442
 */
1424
1531
                        update_site_option( 'illegal_names', $illegal_names );
1425
1532
                }
1426
1533
        }
 
1534
 
 
1535
        // 4.2
 
1536
        if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
 
1537
                if ( ! ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) && DO_NOT_UPGRADE_GLOBAL_TABLES ) ) {
 
1538
                        $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
 
1539
                        $wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
 
1540
                        $wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
 
1541
                        $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
 
1542
 
 
1543
                        $tables = $wpdb->tables( 'global' );
 
1544
 
 
1545
                        foreach ( $tables as $table ) {
 
1546
                                maybe_convert_table_to_utf8mb4( $table );
 
1547
                        }
 
1548
                }
 
1549
        }
1427
1550
}
1428
1551
 
1429
 
// The functions we use to actually do stuff
1430
 
 
1431
 
// General
 
1552
//
 
1553
// General functions we use to actually do stuff
 
1554
//
1432
1555
 
1433
1556
/**
1434
 
 * {@internal Missing Short Description}}
 
1557
 * Creates a table in the database if it doesn't already exist.
1435
1558
 *
1436
 
 * {@internal Missing Long Description}}
 
1559
 * This method checks for an existing database and creates a new one if it's not
 
1560
 * already present. It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses
 
1561
 * to query all tables first and then run the SQL statement creating the table.
1437
1562
 *
1438
1563
 * @since 1.0.0
1439
1564
 *
1461
1586
}
1462
1587
 
1463
1588
/**
1464
 
 * {@internal Missing Short Description}}
1465
 
 *
1466
 
 * {@internal Missing Long Description}}
 
1589
 * Drops a specified index from a table.
1467
1590
 *
1468
1591
 * @since 1.0.1
1469
1592
 *
1484
1607
}
1485
1608
 
1486
1609
/**
1487
 
 * {@internal Missing Short Description}}
1488
 
 *
1489
 
 * {@internal Missing Long Description}}
 
1610
 * Adds an index to a specified table.
1490
1611
 *
1491
1612
 * @since 1.0.1
1492
1613
 *
1502
1623
}
1503
1624
 
1504
1625
/**
1505
 
 ** maybe_add_column()
1506
 
 ** Add column to db table if it doesn't exist.
1507
 
 ** Returns:  true if already exists or on successful completion
1508
 
 **           false on error
 
1626
 * Adds column to a database table if it doesn't already exist.
 
1627
 *
 
1628
 * @since 1.3.0
 
1629
 *
 
1630
 * @param string $table_name  The table name to modify.
 
1631
 * @param string $column_name The column name to add to the table.
 
1632
 * @param string $create_ddl  The SQL statement used to add the column.
 
1633
 * @return True if already exists or on successful completion, false on error.
1509
1634
 */
1510
1635
function maybe_add_column($table_name, $column_name, $create_ddl) {
1511
1636
        global $wpdb;
1528
1653
}
1529
1654
 
1530
1655
/**
 
1656
 * If a table only contains utf8 or utf8mb4 columns, convert it to utf8mb4.
 
1657
 *
 
1658
 * @since 4.2.0
 
1659
 *
 
1660
 * @param string $table The table to convert.
 
1661
 * @return bool true if the table was converted, false if it wasn't.
 
1662
 */
 
1663
function maybe_convert_table_to_utf8mb4( $table ) {
 
1664
        global $wpdb;
 
1665
 
 
1666
        $results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" );
 
1667
        if ( ! $results ) {
 
1668
                return false;
 
1669
        }
 
1670
 
 
1671
        foreach ( $results as $column ) {
 
1672
                if ( $column->Collation ) {
 
1673
                        list( $charset ) = explode( '_', $column->Collation );
 
1674
                        $charset = strtolower( $charset );
 
1675
                        if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
 
1676
                                // Don't upgrade tables that have non-utf8 columns.
 
1677
                                return false;
 
1678
                        }
 
1679
                }
 
1680
        }
 
1681
 
 
1682
        return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
 
1683
}
 
1684
 
 
1685
/**
1531
1686
 * Retrieve all options as it was for 1.2.
1532
1687
 *
1533
1688
 * @since 1.2.0
1548
1703
}
1549
1704
 
1550
1705
/**
1551
 
 * Version of get_option that is private to install/upgrade.
 
1706
 * Utility version of get_option that is private to install/upgrade.
1552
1707
 *
 
1708
 * @ignore
1553
1709
 * @since 1.5.1
1554
1710
 * @access private
1555
1711
 *
1577
1733
}
1578
1734
 
1579
1735
/**
1580
 
 * {@internal Missing Short Description}}
1581
 
 *
1582
 
 * {@internal Missing Long Description}}
 
1736
 * Filters for content to remove unnecessary slashes.
1583
1737
 *
1584
1738
 * @since 1.5.0
1585
1739
 *
1586
 
 * @param string $content
1587
 
 * @return string
 
1740
 * @param string $content The content to modify.
 
1741
 * @return string The de-slashed content.
1588
1742
 */
1589
1743
function deslash($content) {
1590
1744
        // Note: \\\ inside a regex denotes a single backslash.
1608
1762
}
1609
1763
 
1610
1764
/**
1611
 
 * {@internal Missing Short Description}}
 
1765
 * Modifies the database based on specified SQL statements.
1612
1766
 *
1613
 
 * {@internal Missing Long Description}}
 
1767
 * Useful for creating new tables and updating existing tables to a new structure.
1614
1768
 *
1615
1769
 * @since 1.5.0
1616
1770
 *
1617
 
 * @param string $queries
1618
 
 * @param bool   $execute
1619
 
 * @return array
 
1771
 * @param string|array $queries Optional. The query to run. Can be multiple queries
 
1772
 *                              in an array, or a string of queries separated by
 
1773
 *                              semicolons. Default empty.
 
1774
 * @param bool         $execute Optional. Whether or not to execute the query right away.
 
1775
 *                              Default true.
 
1776
 * @return array Strings containing the results of the various update queries.
1620
1777
 */
1621
1778
function dbDelta( $queries = '', $execute = true ) {
1622
1779
        global $wpdb;
1645
1802
 
1646
1803
        // Create a tablename index for an array ($cqueries) of queries
1647
1804
        foreach($queries as $qry) {
1648
 
                if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
 
1805
                if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
1649
1806
                        $cqueries[ trim( $matches[1], '`' ) ] = $qry;
1650
1807
                        $for_update[$matches[1]] = 'Created table '.$matches[1];
1651
 
                } else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
1652
 
                        array_unshift($cqueries, $qry);
1653
 
                } else if (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
 
1808
                } elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) {
 
1809
                        array_unshift( $cqueries, $qry );
 
1810
                } elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) {
1654
1811
                        $iqueries[] = $qry;
1655
 
                } else if (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
 
1812
                } elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) {
1656
1813
                        $iqueries[] = $qry;
1657
1814
                } else {
1658
1815
                        // Unrecognized query type
1786
1943
 
1787
1944
                if ($tableindices) {
1788
1945
                        // Clear the index array.
1789
 
                        unset($index_ary);
 
1946
                        $index_ary = array();
1790
1947
 
1791
1948
                        // For every index in the table.
1792
1949
                        foreach ($tableindices as $tableindex) {
1804
1961
                                $index_string = '';
1805
1962
                                if ($index_name == 'PRIMARY') {
1806
1963
                                        $index_string .= 'PRIMARY ';
1807
 
                                } else if($index_data['unique']) {
 
1964
                                } elseif ( $index_data['unique'] ) {
1808
1965
                                        $index_string .= 'UNIQUE ';
1809
1966
                                }
1810
1967
                                $index_string .= 'KEY ';
1823
1980
                                                $index_columns .= '('.$column_data['subpart'].')';
1824
1981
                                        }
1825
1982
                                }
 
1983
 
 
1984
                                // The alternative index string doesn't care about subparts
 
1985
                                $alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
 
1986
 
1826
1987
                                // Add the column list to the index create string.
1827
 
                                $index_string .= ' ('.$index_columns.')';
1828
 
                                if (!(($aindex = array_search($index_string, $indices)) === false)) {
1829
 
                                        unset($indices[$aindex]);
1830
 
                                        // todo: Remove this?
1831
 
                                        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
 
1988
                                $index_strings = array(
 
1989
                                        "$index_string ($index_columns)",
 
1990
                                        "$index_string ($alt_index_columns)",
 
1991
                                );
 
1992
 
 
1993
                                foreach( $index_strings as $index_string ) {
 
1994
                                        if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
 
1995
                                                unset( $indices[ $aindex ] );
 
1996
                                                break;
 
1997
                                                // todo: Remove this?
 
1998
                                                //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
 
1999
                                        }
1832
2000
                                }
1833
2001
                                // todo: Remove this?
1834
2002
                                //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
1859
2027
}
1860
2028
 
1861
2029
/**
1862
 
 * {@internal Missing Short Description}}
 
2030
 * Updates the database tables to a new schema.
1863
2031
 *
1864
 
 * {@internal Missing Long Description}}
 
2032
 * By default, updates all the tables to use the latest defined schema, but can also
 
2033
 * be used to update a specific set of tables in wp_get_db_schema().
1865
2034
 *
1866
2035
 * @since 1.5.0
 
2036
 *
 
2037
 * @uses dbDelta
 
2038
 *
 
2039
 * @param string $tables Optional. Which set of tables to update. Default is 'all'.
1867
2040
 */
1868
2041
function make_db_current( $tables = 'all' ) {
1869
2042
        $alterations = dbDelta( $tables );
1873
2046
}
1874
2047
 
1875
2048
/**
1876
 
 * {@internal Missing Short Description}}
 
2049
 * Updates the database tables to a new schema, but without displaying results.
1877
2050
 *
1878
 
 * {@internal Missing Long Description}}
 
2051
 * By default, updates all the tables to use the latest defined schema, but can
 
2052
 * also be used to update a specific set of tables in wp_get_db_schema().
1879
2053
 *
1880
2054
 * @since 1.5.0
 
2055
 *
 
2056
 * @see make_db_current()
 
2057
 *
 
2058
 * @param string $tables Optional. Which set of tables to update. Default is 'all'.
1881
2059
 */
1882
2060
function make_db_current_silent( $tables = 'all' ) {
1883
2061
        dbDelta( $tables );
1884
2062
}
1885
2063
 
1886
2064
/**
1887
 
 * {@internal Missing Short Description}}
 
2065
 * Creates a site theme from an existing theme.
1888
2066
 *
1889
2067
 * {@internal Missing Long Description}}
1890
2068
 *
1891
2069
 * @since 1.5.0
1892
2070
 *
1893
 
 * @param string $theme_name
1894
 
 * @param string $template
 
2071
 * @param string $theme_name The name of the theme.
 
2072
 * @param string $template   The directory name of the theme.
1895
2073
 * @return bool
1896
2074
 */
1897
2075
function make_site_theme_from_oldschool($theme_name, $template) {
1967
2145
}
1968
2146
 
1969
2147
/**
1970
 
 * {@internal Missing Short Description}}
 
2148
 * Creates a site theme from the default theme.
1971
2149
 *
1972
2150
 * {@internal Missing Long Description}}
1973
2151
 *
1974
2152
 * @since 1.5.0
1975
2153
 *
1976
 
 * @param string $theme_name
1977
 
 * @param string $template
 
2154
 * @param string $theme_name The name of the theme.
 
2155
 * @param string $template   The directory name of the theme.
1978
2156
 * @return null|false
1979
2157
 */
1980
2158
function make_site_theme_from_default($theme_name, $template) {
2031
2209
        @closedir($images_dir);
2032
2210
}
2033
2211
 
2034
 
// Create a site theme from the default theme.
2035
2212
/**
2036
 
 * {@internal Missing Short Description}}
 
2213
 * Creates a site theme.
2037
2214
 *
2038
2215
 * {@internal Missing Long Description}}
2039
2216
 *
2112
2289
}
2113
2290
 
2114
2291
/**
2115
 
 * {@internal Missing Short Description}}
2116
 
 *
2117
 
 * {@internal Missing Long Description}}
 
2292
 * Checks the version of the installed MySQL binary.
2118
2293
 *
2119
2294
 * @since 2.1.0
2120
2295
 */
2143
2318
}
2144
2319
 
2145
2320
/**
2146
 
 * Disables the Link Manager on upgrade, if at the time of upgrade, no links exist in the DB.
 
2321
 * Disables the Link Manager on upgrade if, at the time of upgrade, no links exist in the DB.
2147
2322
 *
2148
2323
 * @since 3.5.0
2149
2324
 */
2195
2370
                // dbDelta() can recreate but can't drop the index.
2196
2371
                $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug" );
2197
2372
        }
 
2373
 
 
2374
        // Upgrade versions prior to 4.2.
 
2375
        if ( $wp_current_db_version < 31351 ) {
 
2376
                if ( ! is_multisite() ) {
 
2377
                        $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
 
2378
                }
 
2379
                $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
 
2380
                $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" );
 
2381
                $wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
 
2382
                $wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
 
2383
                $wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" );
 
2384
        }
2198
2385
}
2199
2386
 
2200
2387
/**