wp/wp-admin/includes/upgrade.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    29 	 * @since 2.1.0
    29 	 * @since 2.1.0
    30 	 *
    30 	 *
    31 	 * @param string $blog_title    Site title.
    31 	 * @param string $blog_title    Site title.
    32 	 * @param string $user_name     User's username.
    32 	 * @param string $user_name     User's username.
    33 	 * @param string $user_email    User's email.
    33 	 * @param string $user_email    User's email.
    34 	 * @param bool   $public        Whether site is public.
    34 	 * @param bool   $is_public     Whether the site is public.
    35 	 * @param string $deprecated    Optional. Not used.
    35 	 * @param string $deprecated    Optional. Not used.
    36 	 * @param string $user_password Optional. User's chosen password. Default empty (random password).
    36 	 * @param string $user_password Optional. User's chosen password. Default empty (random password).
    37 	 * @param string $language      Optional. Language chosen. Default empty.
    37 	 * @param string $language      Optional. Language chosen. Default empty.
    38 	 * @return array {
    38 	 * @return array {
    39 	 *     Data for the newly installed site.
    39 	 *     Data for the newly installed site.
    42 	 *     @type int    $user_id          The ID of the site owner.
    42 	 *     @type int    $user_id          The ID of the site owner.
    43 	 *     @type string $password         The password of the site owner, if their user account didn't already exist.
    43 	 *     @type string $password         The password of the site owner, if their user account didn't already exist.
    44 	 *     @type string $password_message The explanatory message regarding the password.
    44 	 *     @type string $password_message The explanatory message regarding the password.
    45 	 * }
    45 	 * }
    46 	 */
    46 	 */
    47 	function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
    47 	function wp_install( $blog_title, $user_name, $user_email, $is_public, $deprecated = '', $user_password = '', $language = '' ) {
    48 		if ( ! empty( $deprecated ) ) {
    48 		if ( ! empty( $deprecated ) ) {
    49 			_deprecated_argument( __FUNCTION__, '2.6.0' );
    49 			_deprecated_argument( __FUNCTION__, '2.6.0' );
    50 		}
    50 		}
    51 
    51 
    52 		wp_check_mysql_version();
    52 		wp_check_mysql_version();
    55 		populate_options();
    55 		populate_options();
    56 		populate_roles();
    56 		populate_roles();
    57 
    57 
    58 		update_option( 'blogname', $blog_title );
    58 		update_option( 'blogname', $blog_title );
    59 		update_option( 'admin_email', $user_email );
    59 		update_option( 'admin_email', $user_email );
    60 		update_option( 'blog_public', $public );
    60 		update_option( 'blog_public', $is_public );
    61 
    61 
    62 		// Freshness of site - in the future, this could get more specific about actions taken, perhaps.
    62 		// Freshness of site - in the future, this could get more specific about actions taken, perhaps.
    63 		update_option( 'fresh_site', 1 );
    63 		update_option( 'fresh_site', 1 );
    64 
    64 
    65 		if ( $language ) {
    65 		if ( $language ) {
    69 		$guessurl = wp_guess_url();
    69 		$guessurl = wp_guess_url();
    70 
    70 
    71 		update_option( 'siteurl', $guessurl );
    71 		update_option( 'siteurl', $guessurl );
    72 
    72 
    73 		// If not a public site, don't ping.
    73 		// If not a public site, don't ping.
    74 		if ( ! $public ) {
    74 		if ( ! $is_public ) {
    75 			update_option( 'default_pingback_flag', 0 );
    75 			update_option( 'default_pingback_flag', 0 );
    76 		}
    76 		}
    77 
    77 
    78 		/*
    78 		/*
    79 		 * Create default user. If the user already exists, the user tables are
    79 		 * Create default user. If the user already exists, the user tables are
   247 				'to_ping'               => '',
   247 				'to_ping'               => '',
   248 				'pinged'                => '',
   248 				'pinged'                => '',
   249 				'post_content_filtered' => '',
   249 				'post_content_filtered' => '',
   250 			)
   250 			)
   251 		);
   251 		);
       
   252 
       
   253 		if ( is_multisite() ) {
       
   254 			update_posts_count();
       
   255 		}
       
   256 
   252 		$wpdb->insert(
   257 		$wpdb->insert(
   253 			$wpdb->term_relationships,
   258 			$wpdb->term_relationships,
   254 			array(
   259 			array(
   255 				'term_taxonomy_id' => $cat_tt_id,
   260 				'term_taxonomy_id' => $cat_tt_id,
   256 				'object_id'        => 1,
   261 				'object_id'        => 1,
   265 			$first_comment        = get_site_option( 'first_comment' );
   270 			$first_comment        = get_site_option( 'first_comment' );
   266 		}
   271 		}
   267 
   272 
   268 		$first_comment_author = ! empty( $first_comment_author ) ? $first_comment_author : __( 'A WordPress Commenter' );
   273 		$first_comment_author = ! empty( $first_comment_author ) ? $first_comment_author : __( 'A WordPress Commenter' );
   269 		$first_comment_email  = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example';
   274 		$first_comment_email  = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example';
   270 		$first_comment_url    = ! empty( $first_comment_url ) ? $first_comment_url : 'https://wordpress.org/';
   275 		$first_comment_url    = ! empty( $first_comment_url ) ? $first_comment_url : esc_url( __( 'https://wordpress.org/' ) );
   271 		$first_comment        = ! empty( $first_comment ) ? $first_comment : __(
   276 		$first_comment        = ! empty( $first_comment ) ? $first_comment : sprintf(
   272 			'Hi, this is a comment.
   277 			/* translators: %s: Gravatar URL. */
       
   278 			__(
       
   279 				'Hi, this is a comment.
   273 To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
   280 To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
   274 Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
   281 Commenter avatars come from <a href="%s">Gravatar</a>.'
       
   282 			),
       
   283 			esc_url( __( 'https://en.gravatar.com/' ) )
   275 		);
   284 		);
   276 		$wpdb->insert(
   285 		$wpdb->insert(
   277 			$wpdb->comments,
   286 			$wpdb->comments,
   278 			array(
   287 			array(
   279 				'comment_post_ID'      => 1,
   288 				'comment_post_ID'      => 1,
   830 
   839 
   831 	if ( $wp_current_db_version < 49752 ) {
   840 	if ( $wp_current_db_version < 49752 ) {
   832 		upgrade_560();
   841 		upgrade_560();
   833 	}
   842 	}
   834 
   843 
       
   844 	if ( $wp_current_db_version < 51917 ) {
       
   845 		upgrade_590();
       
   846 	}
       
   847 
       
   848 	if ( $wp_current_db_version < 53011 ) {
       
   849 		upgrade_600();
       
   850 	}
       
   851 
   835 	maybe_disable_link_manager();
   852 	maybe_disable_link_manager();
   836 
   853 
   837 	maybe_disable_automattic_widgets();
   854 	maybe_disable_automattic_widgets();
   838 
   855 
   839 	update_option( 'db_version', $wp_db_version );
   856 	update_option( 'db_version', $wp_db_version );
  1610 	}
  1627 	}
  1611 	if ( is_multisite() ) {
  1628 	if ( is_multisite() ) {
  1612 		$start = 0;
  1629 		$start = 0;
  1613 		while ( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
  1630 		while ( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
  1614 			foreach ( $rows as $row ) {
  1631 			foreach ( $rows as $row ) {
  1615 				$value = $row->option_value;
  1632 				$value = maybe_unserialize( $row->option_value );
  1616 				if ( ! @unserialize( $value ) ) {
  1633 				if ( $value === $row->option_value ) {
  1617 					$value = stripslashes( $value );
  1634 					$value = stripslashes( $value );
  1618 				}
  1635 				}
  1619 				if ( $value !== $row->option_value ) {
  1636 				if ( $value !== $row->option_value ) {
  1620 					update_option( $row->option_name, $value );
  1637 					update_option( $row->option_name, $value );
  1621 				}
  1638 				}
  1872 /**
  1889 /**
  1873  * Execute changes made in WordPress 3.7.2.
  1890  * Execute changes made in WordPress 3.7.2.
  1874  *
  1891  *
  1875  * @ignore
  1892  * @ignore
  1876  * @since 3.7.2
  1893  * @since 3.7.2
  1877  * @since 3.8.0
       
  1878  *
  1894  *
  1879  * @global int $wp_current_db_version The old (current) database version.
  1895  * @global int $wp_current_db_version The old (current) database version.
  1880  */
  1896  */
  1881 function upgrade_372() {
  1897 function upgrade_372() {
  1882 	global $wp_current_db_version;
  1898 	global $wp_current_db_version;
  2243 
  2259 
  2244 		if ( ! empty( $results ) ) {
  2260 		if ( ! empty( $results ) ) {
  2245 			$network_id = get_main_network_id();
  2261 			$network_id = get_main_network_id();
  2246 			update_network_option( $network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1 );
  2262 			update_network_option( $network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1 );
  2247 		}
  2263 		}
       
  2264 	}
       
  2265 }
       
  2266 
       
  2267 /**
       
  2268  * Executes changes made in WordPress 5.9.0.
       
  2269  *
       
  2270  * @ignore
       
  2271  * @since 5.9.0
       
  2272  *
       
  2273  * @global int $wp_current_db_version The old (current) database version.
       
  2274  */
       
  2275 function upgrade_590() {
       
  2276 	global $wp_current_db_version;
       
  2277 
       
  2278 	if ( $wp_current_db_version < 51917 ) {
       
  2279 		$crons = _get_cron_array();
       
  2280 
       
  2281 		if ( $crons && is_array( $crons ) ) {
       
  2282 			// Remove errant `false` values, see #53950, #54906.
       
  2283 			$crons = array_filter( $crons );
       
  2284 			_set_cron_array( $crons );
       
  2285 		}
       
  2286 	}
       
  2287 }
       
  2288 
       
  2289 /**
       
  2290  * Executes changes made in WordPress 6.0.0.
       
  2291  *
       
  2292  * @ignore
       
  2293  * @since 6.0.0
       
  2294  *
       
  2295  * @global int $wp_current_db_version The old (current) database version.
       
  2296  */
       
  2297 function upgrade_600() {
       
  2298 	global $wp_current_db_version;
       
  2299 
       
  2300 	if ( $wp_current_db_version < 53011 ) {
       
  2301 		wp_update_user_counts();
  2248 	}
  2302 	}
  2249 }
  2303 }
  2250 
  2304 
  2251 /**
  2305 /**
  2252  * Executes network-level upgrade routines.
  2306  * Executes network-level upgrade routines.