diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/schema.php --- a/wp/wp-admin/includes/schema.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/schema.php Fri Sep 05 18:40:08 2025 +0200 @@ -38,7 +38,7 @@ $charset_collate = $wpdb->get_charset_collate(); - if ( $blog_id && $blog_id != $wpdb->blogid ) { + if ( $blog_id && (int) $blog_id !== $wpdb->blogid ) { $old_blog_id = $wpdb->set_blog_id( $blog_id ); } @@ -388,21 +388,30 @@ /* * translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) * or a valid timezone string (America/New_York). See https://www.php.net/manual/en/timezones.php - * for all timezone strings supported by PHP. + * for all timezone strings currently supported by PHP. + * + * Important: When a previous timezone string, like `Europe/Kiev`, has been superseded by an + * updated one, like `Europe/Kyiv`, as a rule of thumb, the **old** timezone name should be used + * in the "translation" to allow for the default timezone setting to be PHP cross-version compatible, + * as old timezone names will be recognized in new PHP versions, while new timezone names cannot + * be recognized in old PHP versions. + * + * To verify which timezone strings are available in the _oldest_ PHP version supported, you can + * use https://3v4l.org/6YQAt#v5.6.20 and replace the "BR" (Brazil) in the code line with the + * country code for which you want to look up the supported timezone names. */ $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); if ( is_numeric( $offset_or_tz ) ) { $gmt_offset = $offset_or_tz; - } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list(), true ) ) { - $timezone_string = $offset_or_tz; + } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ), true ) ) { + $timezone_string = $offset_or_tz; } $defaults = array( 'siteurl' => $guessurl, 'home' => $guessurl, 'blogname' => __( 'My Site' ), - /* translators: Site tagline. */ - 'blogdescription' => __( 'Just another WordPress site' ), + 'blogdescription' => '', 'users_can_register' => 0, 'admin_email' => 'you@example.com', /* translators: Default start of the week. 0 = Sunday, 1 = Monday. */ @@ -539,12 +548,17 @@ // 5.6.0 'auto_update_core_dev' => 'enabled', 'auto_update_core_minor' => 'enabled', - // Default to enabled for new installs. - // See https://core.trac.wordpress.org/ticket/51742. + /* + * Default to enabled for new installs. + * See https://core.trac.wordpress.org/ticket/51742. + */ 'auto_update_core_major' => 'enabled', // 5.8.0 'wp_force_deactivated_plugins' => array(), + + // 6.4.0 + 'wp_attachment_pages_enabled' => 0, ); // 3.3.0 @@ -555,8 +569,6 @@ // 3.0.0 multisite. if ( is_multisite() ) { - /* translators: %s: Network title. */ - $defaults['blogdescription'] = sprintf( __( 'Just another %s site' ), get_network()->site_name ); $defaults['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/'; } @@ -582,19 +594,17 @@ } if ( in_array( $option, $fat_options, true ) ) { - $autoload = 'no'; + $autoload = 'off'; } else { - $autoload = 'yes'; - } - - if ( is_array( $value ) ) { - $value = serialize( $value ); + $autoload = 'on'; } if ( ! empty( $insert ) ) { $insert .= ', '; } + $value = maybe_serialize( sanitize_option( $option, $value ) ); + $insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload ); } @@ -970,12 +980,14 @@ * @param string $path Optional. The path to append to the network's domain name. Default '/'. * @param bool $subdomain_install Optional. Whether the network is a subdomain installation or a subdirectory installation. * Default false, meaning the network is a subdirectory installation. - * @return bool|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful, + * @return true|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful, * so the error code must be checked) or failure. */ function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) { global $wpdb, $current_site, $wp_rewrite; + $network_id = (int) $network_id; + $errors = new WP_Error(); if ( '' === $domain ) { $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); @@ -987,11 +999,13 @@ // Check for network collision. $network_exists = false; if ( is_multisite() ) { - if ( get_network( (int) $network_id ) ) { + if ( get_network( $network_id ) ) { $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); } } else { - if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) { + if ( $network_id === (int) $wpdb->get_var( + $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) + ) ) { $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); } } @@ -1004,7 +1018,7 @@ return $errors; } - if ( 1 == $network_id ) { + if ( 1 === $network_id ) { $wpdb->insert( $wpdb->site, array( @@ -1033,8 +1047,6 @@ ) ); - $site_user = get_userdata( (int) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", 'admin_user_id', $network_id ) ) ); - /* * When upgrading from single to multisite, assume the current site will * become the main site of the network. When using populate_network() @@ -1043,7 +1055,7 @@ * created. */ if ( ! is_multisite() ) { - $current_site = new stdClass; + $current_site = new stdClass(); $current_site->domain = $domain; $current_site->path = $path; $current_site->site_name = ucfirst( $domain ); @@ -1058,8 +1070,29 @@ ) ); $current_site->blog_id = $wpdb->insert_id; - update_user_meta( $site_user->ID, 'source_domain', $domain ); - update_user_meta( $site_user->ID, 'primary_blog', $current_site->blog_id ); + + $site_user_id = (int) $wpdb->get_var( + $wpdb->prepare( + "SELECT meta_value + FROM $wpdb->sitemeta + WHERE meta_key = %s AND site_id = %d", + 'admin_user_id', + $network_id + ) + ); + + update_user_meta( $site_user_id, 'source_domain', $domain ); + update_user_meta( $site_user_id, 'primary_blog', $current_site->blog_id ); + + // Unable to use update_network_option() while populating the network. + $wpdb->insert( + $wpdb->sitemeta, + array( + 'site_id' => $network_id, + 'meta_key' => 'main_site', + 'meta_value' => $current_site->blog_id, + ) + ); if ( $subdomain_install ) { $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); @@ -1085,7 +1118,7 @@ ); if ( is_wp_error( $page ) ) { $errstr = $page->get_error_message(); - } elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) { + } elseif ( 200 === wp_remote_retrieve_response_code( $page ) ) { $vhost_ok = true; } @@ -1151,11 +1184,11 @@ $stylesheet = get_option( 'stylesheet' ); $allowed_themes = array( $stylesheet => true ); - if ( $template != $stylesheet ) { + if ( $template !== $stylesheet ) { $allowed_themes[ $template ] = true; } - if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) { + if ( WP_DEFAULT_THEME !== $stylesheet && WP_DEFAULT_THEME !== $template ) { $allowed_themes[ WP_DEFAULT_THEME ] = true; } @@ -1210,38 +1243,13 @@ --The Team @ SITE_NAME' ); - $misc_exts = array( - // Images. - 'jpg', - 'jpeg', - 'png', - 'gif', - 'webp', - // Video. - 'mov', - 'avi', - 'mpg', - '3gp', - '3g2', - // "audio". - 'midi', - 'mid', - // Miscellaneous. - 'pdf', - 'doc', - 'ppt', - 'odt', - 'pptx', - 'docx', - 'pps', - 'ppsx', - 'xls', - 'xlsx', - 'key', - ); - $audio_exts = wp_get_audio_extensions(); - $video_exts = wp_get_video_extensions(); - $upload_filetypes = array_unique( array_merge( $misc_exts, $audio_exts, $video_exts ) ); + $allowed_file_types = array(); + $all_mime_types = get_allowed_mime_types(); + + foreach ( $all_mime_types as $ext => $mime ) { + array_push( $allowed_file_types, ...explode( '|', $ext ) ); + } + $upload_filetypes = array_unique( $allowed_file_types ); $sitemeta = array( 'site_name' => __( 'My Network' ), @@ -1263,7 +1271,6 @@ 'add_new_users' => '0', 'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', 'subdomain_install' => $subdomain_install, - 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', 'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', 'user_count' => get_site_option( 'user_count' ), 'initial_db_version' => get_option( 'initial_db_version' ),