--- a/wp/wp-admin/includes/upgrade.php Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/includes/upgrade.php Wed Sep 21 18:19:35 2022 +0200
@@ -88,7 +88,7 @@
$user_password = wp_generate_password( 12, false );
$message = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.' );
$user_id = wp_create_user( $user_name, $user_password, $user_email );
- update_user_option( $user_id, 'default_password_nag', true, true );
+ update_user_meta( $user_id, 'default_password_nag', true );
$email_password = true;
$user_created = true;
} elseif ( ! $user_id ) {
@@ -403,59 +403,13 @@
// Set up default widgets for default theme.
update_option(
- 'widget_search',
- array(
- 2 => array( 'title' => '' ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_recent-posts',
- array(
- 2 => array(
- 'title' => '',
- 'number' => 5,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_recent-comments',
+ 'widget_block',
array(
- 2 => array(
- 'title' => '',
- 'number' => 5,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_archives',
- array(
- 2 => array(
- 'title' => '',
- 'count' => 0,
- 'dropdown' => 0,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_categories',
- array(
- 2 => array(
- 'title' => '',
- 'count' => 0,
- 'hierarchical' => 0,
- 'dropdown' => 0,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_meta',
- array(
- 2 => array( 'title' => '' ),
+ 2 => array( 'content' => '<!-- wp:search /-->' ),
+ 3 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Recent Posts' ) . '</h2><!-- /wp:heading --><!-- wp:latest-posts /--></div><!-- /wp:group -->' ),
+ 4 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Recent Comments' ) . '</h2><!-- /wp:heading --><!-- wp:latest-comments {"displayAvatar":false,"displayDate":false,"displayExcerpt":false} /--></div><!-- /wp:group -->' ),
+ 5 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Archives' ) . '</h2><!-- /wp:heading --><!-- wp:archives /--></div><!-- /wp:group -->' ),
+ 6 => array( 'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>' . __( 'Categories' ) . '</h2><!-- /wp:heading --><!-- wp:categories /--></div><!-- /wp:group -->' ),
'_multiwidget' => 1,
)
);
@@ -464,18 +418,18 @@
array(
'wp_inactive_widgets' => array(),
'sidebar-1' => array(
- 0 => 'search-2',
- 1 => 'recent-posts-2',
- 2 => 'recent-comments-2',
+ 0 => 'block-2',
+ 1 => 'block-3',
+ 2 => 'block-4',
),
'sidebar-2' => array(
- 0 => 'archives-2',
- 1 => 'categories-2',
- 2 => 'meta-2',
+ 0 => 'block-5',
+ 1 => 'block-6',
),
'array_version' => 3,
)
);
+
if ( ! is_multisite() ) {
update_user_meta( $user_id, 'show_welcome_panel', 1 );
} elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) {
@@ -586,17 +540,18 @@
if ( ! function_exists( 'wp_new_blog_notification' ) ) :
/**
- * Notifies the site admin that the setup is complete.
+ * Notifies the site admin that the installation of WordPress is complete.
*
- * Sends an email with wp_mail to the new administrator that the site setup is complete,
+ * Sends an email to the new administrator that the installation is complete
* and provides them with a record of their login credentials.
*
* @since 2.1.0
*
* @param string $blog_title Site title.
- * @param string $blog_url Site url.
- * @param int $user_id User ID.
- * @param string $password User's Password.
+ * @param string $blog_url Site URL.
+ * @param int $user_id Administrator's user ID.
+ * @param string $password Administrator's password. Note that a placeholder message is
+ * usually passed instead of the actual password.
*/
function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password ) {
$user = new WP_User( $user_id );
@@ -629,7 +584,40 @@
$login_url
);
- wp_mail( $email, __( 'New WordPress Site' ), $message );
+ $installed_email = array(
+ 'to' => $email,
+ 'subject' => __( 'New WordPress Site' ),
+ 'message' => $message,
+ 'headers' => '',
+ );
+
+ /**
+ * Filters the contents of the email sent to the site administrator when WordPress is installed.
+ *
+ * @since 5.6.0
+ *
+ * @param array $installed_email {
+ * Used to build wp_mail().
+ *
+ * @type string $to The email address of the recipient.
+ * @type string $subject The subject of the email.
+ * @type string $message The content of the email.
+ * @type string $headers Headers.
+ * }
+ * @param WP_User $user The site administrator user object.
+ * @param string $blog_title The site title.
+ * @param string $blog_url The site URL.
+ * @param string $password The site administrator's password. Note that a placeholder message
+ * is usually passed instead of the user's actual password.
+ */
+ $installed_email = apply_filters( 'wp_installed_email', $installed_email, $user, $blog_title, $blog_url, $password );
+
+ wp_mail(
+ $installed_email['to'],
+ $installed_email['subject'],
+ $installed_email['message'],
+ $installed_email['headers']
+ );
}
endif;
@@ -840,6 +828,10 @@
upgrade_550();
}
+ if ( $wp_current_db_version < 49752 ) {
+ upgrade_560();
+ }
+
maybe_disable_link_manager();
maybe_disable_automattic_widgets();
@@ -988,8 +980,8 @@
if ( ! $got_gmt_fields ) {
// Add or subtract time to all dates, to get GMT dates.
- $add_hours = intval( $diff_gmt_weblogger );
- $add_minutes = intval( 60 * ( $diff_gmt_weblogger - $add_hours ) );
+ $add_hours = (int) $diff_gmt_weblogger;
+ $add_minutes = (int) ( 60 * ( $diff_gmt_weblogger - $add_hours ) );
$wpdb->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
$wpdb->query( "UPDATE $wpdb->posts SET post_modified = post_date" );
$wpdb->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" );
@@ -1078,7 +1070,7 @@
$limit = $option->dupes - 1;
$dupe_ids = $wpdb->get_col( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit ) );
if ( $dupe_ids ) {
- $dupe_ids = join( ',', $dupe_ids );
+ $dupe_ids = implode( ',', $dupe_ids );
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)" );
}
}
@@ -2014,7 +2006,7 @@
return;
}
- $allowed_length = intval( $content_length['length'] ) - 10;
+ $allowed_length = (int) $content_length['length'] - 10;
$comments = $wpdb->get_results(
"SELECT `comment_ID` FROM `{$wpdb->comments}`
@@ -2203,6 +2195,60 @@
}
/**
+ * Executes changes made in WordPress 5.6.0.
+ *
+ * @ignore
+ * @since 5.6.0
+ */
+function upgrade_560() {
+ global $wp_current_db_version, $wpdb;
+
+ if ( $wp_current_db_version < 49572 ) {
+ /*
+ * Clean up the `post_category` column removed from schema in version 2.8.0.
+ * Its presence may conflict with `WP_Post::__get()`.
+ */
+ $post_category_exists = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->posts LIKE 'post_category'" );
+ if ( ! is_null( $post_category_exists ) ) {
+ $wpdb->query( "ALTER TABLE $wpdb->posts DROP COLUMN `post_category`" );
+ }
+
+ /*
+ * When upgrading from WP < 5.6.0 set the core major auto-updates option to `unset` by default.
+ * This overrides the same option from populate_options() that is intended for new installs.
+ * See https://core.trac.wordpress.org/ticket/51742.
+ */
+ update_option( 'auto_update_core_major', 'unset' );
+ }
+
+ if ( $wp_current_db_version < 49632 ) {
+ /*
+ * Regenerate the .htaccess file to add the `HTTP_AUTHORIZATION` rewrite rule.
+ * See https://core.trac.wordpress.org/ticket/51723.
+ */
+ save_mod_rewrite_rules();
+ }
+
+ if ( $wp_current_db_version < 49735 ) {
+ delete_transient( 'dirsize_cache' );
+ }
+
+ if ( $wp_current_db_version < 49752 ) {
+ $results = $wpdb->get_results(
+ $wpdb->prepare(
+ "SELECT 1 FROM {$wpdb->usermeta} WHERE meta_key = %s LIMIT 1",
+ WP_Application_Passwords::USERMETA_KEY_APPLICATION_PASSWORDS
+ )
+ );
+
+ if ( ! empty( $results ) ) {
+ $network_id = get_main_network_id();
+ update_network_option( $network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1 );
+ }
+ }
+}
+
+/**
* Executes network-level upgrade routines.
*
* @since 3.0.0
@@ -3456,6 +3502,8 @@
/**
* Filters if upgrade routines should be run on global tables.
*
+ * @since 4.3.0
+ *
* @param bool $should_upgrade Whether to run the upgrade routines on global tables.
*/
return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );