X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..3d39054f012aefe514b3f5509e32f09fc4feda44:/wp-admin/includes/upgrade.php diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 72d99b77..807673a7 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -27,10 +27,10 @@ if ( !function_exists('wp_install') ) : * * @since 2.1.0 * - * @param string $blog_title Blog title. + * @param string $blog_title Site title. * @param string $user_name User's username. * @param string $user_email User's email. - * @param bool $public Whether blog is public. + * @param bool $public Whether site is public. * @param string $deprecated Optional. Not used. * @param string $user_password Optional. User's chosen password. Default empty (random password). * @param string $language Optional. Language chosen. Default empty. @@ -38,7 +38,7 @@ if ( !function_exists('wp_install') ) : */ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { if ( !empty( $deprecated ) ) - _deprecated_argument( __FUNCTION__, '2.6' ); + _deprecated_argument( __FUNCTION__, '2.6.0' ); wp_check_mysql_version(); wp_cache_flush(); @@ -64,7 +64,7 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated /* * Create default user. If the user already exists, the user tables are - * being shared among blogs. Just set the role in that case. + * being shared among sites. Just set the role in that case. */ $user_id = username_exists($user_name); $user_password = trim($user_password); @@ -191,19 +191,22 @@ function wp_install_defaults( $user_id ) { $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) ); // Default comment - $first_comment_author = __('Mr WordPress'); + $first_comment_author = __( 'A WordPress Commenter' ); + $first_comment_email = 'wapuu@wordpress.example'; $first_comment_url = 'https://wordpress.org/'; - $first_comment = __('Hi, this is a comment. -To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.'); + $first_comment = __( 'Hi, this is a comment. +To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard. +Commenter avatars come from Gravatar.' ); if ( is_multisite() ) { $first_comment_author = get_site_option( 'first_comment_author', $first_comment_author ); + $first_comment_email = get_site_option( 'first_comment_email', $first_comment_email ); $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); $first_comment = get_site_option( 'first_comment', $first_comment ); } $wpdb->insert( $wpdb->comments, array( 'comment_post_ID' => 1, 'comment_author' => $first_comment_author, - 'comment_author_email' => '', + 'comment_author_email' => $first_comment_email, 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, @@ -317,11 +320,12 @@ function wp_install_maybe_enable_pretty_permalinks() { */ $wp_rewrite->flush_rules( true ); - // Test against a real WordPress Post, or if none were created, a random 404 page. - $test_url = get_permalink( 1 ); + $test_url = ''; - if ( ! $test_url ) { - $test_url = home_url( '/wordpress-check-for-rewrites/' ); + // Test against a real WordPress Post + $first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' ); + if ( $first_post ) { + $test_url = get_permalink( $first_post->ID ); } /* @@ -359,8 +363,8 @@ if ( !function_exists('wp_new_blog_notification') ) : * * @since 2.1.0 * - * @param string $blog_title Blog title. - * @param string $blog_url Blog url. + * @param string $blog_title Site title. + * @param string $blog_url Site url. * @param int $user_id User ID. * @param string $password User's Password. */ @@ -447,6 +451,7 @@ endif; * Contains conditional checks to determine which upgrade scripts to run, * based on database version and WP version being updated-to. * + * @ignore * @since 1.0.1 * * @global int $wp_current_db_version @@ -548,6 +553,12 @@ function upgrade_all() { if ( $wp_current_db_version < 35700 ) upgrade_440(); + if ( $wp_current_db_version < 36686 ) + upgrade_450(); + + if ( $wp_current_db_version < 37965 ) + upgrade_460(); + maybe_disable_link_manager(); maybe_disable_automattic_widgets(); @@ -559,6 +570,7 @@ function upgrade_all() { /** * Execute changes made in WordPress 1.0. * + * @ignore * @since 1.0.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -617,6 +629,7 @@ function upgrade_100() { /** * Execute changes made in WordPress 1.0.1. * + * @ignore * @since 1.0.1 * * @global wpdb $wpdb WordPress database abstraction object. @@ -637,6 +650,7 @@ function upgrade_101() { /** * Execute changes made in WordPress 1.2. * + * @ignore * @since 1.2.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -699,6 +713,7 @@ function upgrade_110() { /** * Execute changes made in WordPress 1.5. * + * @ignore * @since 1.5.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -785,6 +800,7 @@ function upgrade_130() { /** * Execute changes made in WordPress 2.0. * + * @ignore * @since 2.0.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -871,6 +887,7 @@ function upgrade_160() { /** * Execute changes made in WordPress 2.1. * + * @ignore * @since 2.1.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -918,6 +935,7 @@ function upgrade_210() { /** * Execute changes made in WordPress 2.3. * + * @ignore * @since 2.3.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -1097,6 +1115,7 @@ function upgrade_230() { /** * Remove old options from the database. * + * @ignore * @since 2.3.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -1113,6 +1132,7 @@ function upgrade_230_options_table() { /** * Remove old categories, link2cat, and post2cat database tables. * + * @ignore * @since 2.3.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -1127,6 +1147,7 @@ function upgrade_230_old_tables() { /** * Upgrade old slugs made in version 2.2. * + * @ignore * @since 2.2.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -1140,6 +1161,7 @@ function upgrade_old_slugs() { /** * Execute changes made in WordPress 2.5.0. * + * @ignore * @since 2.5.0 * * @global int $wp_current_db_version @@ -1156,6 +1178,7 @@ function upgrade_250() { /** * Execute changes made in WordPress 2.5.2. * + * @ignore * @since 2.5.2 * * @global wpdb $wpdb WordPress database abstraction object. @@ -1169,6 +1192,7 @@ function upgrade_252() { /** * Execute changes made in WordPress 2.6. * + * @ignore * @since 2.6.0 * * @global int $wp_current_db_version @@ -1183,6 +1207,7 @@ function upgrade_260() { /** * Execute changes made in WordPress 2.7. * + * @ignore * @since 2.7.0 * * @global wpdb $wpdb WordPress database abstraction object. @@ -1202,6 +1227,7 @@ function upgrade_270() { /** * Execute changes made in WordPress 2.8. * + * @ignore * @since 2.8.0 * * @global int $wp_current_db_version @@ -1232,6 +1258,7 @@ function upgrade_280() { /** * Execute changes made in WordPress 2.9. * + * @ignore * @since 2.9.0 * * @global int $wp_current_db_version @@ -1251,6 +1278,7 @@ function upgrade_290() { /** * Execute changes made in WordPress 3.0. * + * @ignore * @since 3.0.0 * * @global int $wp_current_db_version @@ -1296,6 +1324,7 @@ function upgrade_300() { /** * Execute changes made in WordPress 3.3. * + * @ignore * @since 3.3.0 * * @global int $wp_current_db_version @@ -1370,6 +1399,7 @@ function upgrade_330() { /** * Execute changes made in WordPress 3.4. * + * @ignore * @since 3.4.0 * * @global int $wp_current_db_version @@ -1406,6 +1436,7 @@ function upgrade_340() { /** * Execute changes made in WordPress 3.5. * + * @ignore * @since 3.5.0 * * @global int $wp_current_db_version @@ -1436,6 +1467,7 @@ function upgrade_350() { /** * Execute changes made in WordPress 3.7. * + * @ignore * @since 3.7.0 * * @global int $wp_current_db_version @@ -1449,6 +1481,7 @@ function upgrade_370() { /** * Execute changes made in WordPress 3.7.2. * + * @ignore * @since 3.7.2 * @since 3.8.0 * @@ -1463,6 +1496,7 @@ function upgrade_372() { /** * Execute changes made in WordPress 3.8.0. * + * @ignore * @since 3.8.0 * * @global int $wp_current_db_version @@ -1477,6 +1511,7 @@ function upgrade_380() { /** * Execute changes made in WordPress 4.0.0. * + * @ignore * @since 4.0.0 * * @global int $wp_current_db_version @@ -1497,6 +1532,7 @@ function upgrade_400() { /** * Execute changes made in WordPress 4.2.0. * + * @ignore * @since 4.2.0 * * @global int $wp_current_db_version @@ -1507,6 +1543,7 @@ function upgrade_420() {} /** * Executes changes made in WordPress 4.3.0. * + * @ignore * @since 4.3.0 * * @global int $wp_current_db_version Current version. @@ -1545,6 +1582,7 @@ function upgrade_430() { /** * Executes comments changes made in WordPress 4.3.0. * + * @ignore * @since 4.3.0 * * @global int $wp_current_db_version Current version. @@ -1594,6 +1632,7 @@ function upgrade_430_fix_comments() { /** * Executes changes made in WordPress 4.3.1. * + * @ignore * @since 4.3.1 */ function upgrade_431() { @@ -1608,6 +1647,7 @@ function upgrade_431() { /** * Executes changes made in WordPress 4.4.0. * + * @ignore * @since 4.4.0 * * @global int $wp_current_db_version Current version. @@ -1629,6 +1669,63 @@ function upgrade_440() { } } +/** + * Executes changes made in WordPress 4.5.0. + * + * @ignore + * @since 4.5.0 + * + * @global int $wp_current_db_version Current database version. + * @global wpdb $wpdb WordPress database abstraction object. + */ +function upgrade_450() { + global $wp_current_db_version, $wpdb; + + if ( $wp_current_db_version < 36180 ) { + wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); + } + + // Remove unused email confirmation options, moved to usermeta. + if ( $wp_current_db_version < 36679 && is_multisite() ) { + $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" ); + } + + // Remove unused user setting for wpLink. + delete_user_setting( 'wplink' ); +} + +/** + * Executes changes made in WordPress 4.6.0. + * + * @ignore + * @since 4.6.0 + * + * @global int $wp_current_db_version Current database version. + */ +function upgrade_460() { + global $wp_current_db_version; + + // Remove unused post meta. + if ( $wp_current_db_version < 37854 ) { + delete_post_meta_by_key( '_post_restored_from' ); + } + + // Remove plugins with callback as an array object/method as the uninstall hook, see #13786. + if ( $wp_current_db_version < 37965 ) { + $uninstall_plugins = get_option( 'uninstall_plugins', array() ); + + if ( ! empty( $uninstall_plugins ) ) { + foreach ( $uninstall_plugins as $basename => $callback ) { + if ( is_array( $callback ) && is_object( $callback[0] ) ) { + unset( $uninstall_plugins[ $basename ] ); + } + } + + update_option( 'uninstall_plugins', $uninstall_plugins ); + } + } +} + /** * Executes network-level upgrade routines. * @@ -2046,7 +2143,7 @@ function dbDelta( $queries = '', $execute = true ) { } /** - * Filter the dbDelta SQL queries. + * Filters the dbDelta SQL queries. * * @since 3.3.0 * @@ -2075,7 +2172,7 @@ function dbDelta( $queries = '', $execute = true ) { } /** - * Filter the dbDelta SQL queries for creating tables and/or databases. + * Filters the dbDelta SQL queries for creating tables and/or databases. * * Queries filterable via this hook contain "CREATE TABLE" or "CREATE DATABASE". * @@ -2086,7 +2183,7 @@ function dbDelta( $queries = '', $execute = true ) { $cqueries = apply_filters( 'dbdelta_create_queries', $cqueries ); /** - * Filter the dbDelta SQL queries for inserting or updating. + * Filters the dbDelta SQL queries for inserting or updating. * * Queries filterable via this hook contain "INSERT INTO" or "UPDATE". * @@ -2096,6 +2193,9 @@ function dbDelta( $queries = '', $execute = true ) { */ $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); + $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' ); + $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' ); + $global_tables = $wpdb->tables( 'global' ); foreach ( $cqueries as $table => $qry ) { // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. @@ -2122,68 +2222,168 @@ function dbDelta( $queries = '', $execute = true ) { // Separate field lines into an array. $flds = explode("\n", $qryline); - // todo: Remove this? - //echo "
\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."
{$table}:\n"; } } - // todo: Remove this? - //else echo "
Found index:".$index_string."
{$table}:\n"; } } @@ -2279,8 +2480,6 @@ function dbDelta( $queries = '', $execute = true ) { $allqueries = array_merge($cqueries, $iqueries); if ($execute) { foreach ($allqueries as $query) { - // todo: Remove this? - //echo "
Did not find index:".$index_string."
".print_r($indices, true)."
".print_r($query, true)."\n"; $wpdb->query($query); } } @@ -2724,7 +2923,7 @@ function wp_should_upgrade_global_tables() { } /** - * Filter if upgrade routines should be run on global tables. + * Filters if upgrade routines should be run on global tables. * * @param bool $should_upgrade Whether to run the upgrade routines on global tables. */