wp/wp-admin/includes/update-core.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   824 	'wp-includes/blocks/subhead',
   824 	'wp-includes/blocks/subhead',
   825 	'wp-includes/css/dist/editor/editor-styles.css',
   825 	'wp-includes/css/dist/editor/editor-styles.css',
   826 	'wp-includes/css/dist/editor/editor-styles.min.css',
   826 	'wp-includes/css/dist/editor/editor-styles.min.css',
   827 	'wp-includes/css/dist/editor/editor-styles-rtl.css',
   827 	'wp-includes/css/dist/editor/editor-styles-rtl.css',
   828 	'wp-includes/css/dist/editor/editor-styles-rtl.min.css',
   828 	'wp-includes/css/dist/editor/editor-styles-rtl.min.css',
       
   829 	// 5.9
       
   830 	'wp-includes/blocks/heading/editor.css',
       
   831 	'wp-includes/blocks/heading/editor.min.css',
       
   832 	'wp-includes/blocks/heading/editor-rtl.css',
       
   833 	'wp-includes/blocks/heading/editor-rtl.min.css',
       
   834 	'wp-includes/blocks/post-content/editor.css',
       
   835 	'wp-includes/blocks/post-content/editor.min.css',
       
   836 	'wp-includes/blocks/post-content/editor-rtl.css',
       
   837 	'wp-includes/blocks/post-content/editor-rtl.min.css',
       
   838 	'wp-includes/blocks/query-title/editor.css',
       
   839 	'wp-includes/blocks/query-title/editor.min.css',
       
   840 	'wp-includes/blocks/query-title/editor-rtl.css',
       
   841 	'wp-includes/blocks/query-title/editor-rtl.min.css',
       
   842 	'wp-includes/blocks/tag-cloud/editor.css',
       
   843 	'wp-includes/blocks/tag-cloud/editor.min.css',
       
   844 	'wp-includes/blocks/tag-cloud/editor-rtl.css',
       
   845 	'wp-includes/blocks/tag-cloud/editor-rtl.min.css',
       
   846 	// 6.0
       
   847 	'wp-content/themes/twentytwentytwo/assets/fonts/LICENSE.md',
   829 );
   848 );
   830 
   849 
   831 /**
   850 /**
   832  * Stores new files in wp-content to copy
   851  * Stores new files in wp-content to copy
   833  *
   852  *
   862 	'themes/twentysixteen/'   => '4.4',
   881 	'themes/twentysixteen/'   => '4.4',
   863 	'themes/twentyseventeen/' => '4.7',
   882 	'themes/twentyseventeen/' => '4.7',
   864 	'themes/twentynineteen/'  => '5.0',
   883 	'themes/twentynineteen/'  => '5.0',
   865 	'themes/twentytwenty/'    => '5.3',
   884 	'themes/twentytwenty/'    => '5.3',
   866 	'themes/twentytwentyone/' => '5.6',
   885 	'themes/twentytwentyone/' => '5.6',
       
   886 	'themes/twentytwentytwo/' => '5.9',
   867 );
   887 );
   868 
   888 
   869 /**
   889 /**
   870  * Upgrades the core of WordPress.
   890  * Upgrades the core of WordPress.
   871  *
   891  *
   963 		return new WP_Error( 'insane_distro', __( 'The update could not be unpacked' ) );
   983 		return new WP_Error( 'insane_distro', __( 'The update could not be unpacked' ) );
   964 	}
   984 	}
   965 
   985 
   966 	/*
   986 	/*
   967 	 * Import $wp_version, $required_php_version, and $required_mysql_version from the new version.
   987 	 * Import $wp_version, $required_php_version, and $required_mysql_version from the new version.
   968 	 * DO NOT globalise any variables imported from `version-current.php` in this function.
   988 	 * DO NOT globalize any variables imported from `version-current.php` in this function.
   969 	 *
   989 	 *
   970 	 * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8.
   990 	 * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8.
   971 	 */
   991 	 */
   972 	$versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
   992 	$versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
   973 
   993 
   974 	if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
   994 	if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
   975 		$wp_filesystem->delete( $from, true );
   995 		$wp_filesystem->delete( $from, true );
   976 
   996 
   977 		return new WP_Error(
   997 		return new WP_Error(
   978 			'copy_failed_for_version_file',
   998 			'copy_failed_for_version_file',
   979 			__( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ),
   999 			__( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' ),
   980 			'wp-includes/version.php'
  1000 			'wp-includes/version.php'
   981 		);
  1001 		);
   982 	}
  1002 	}
   983 
  1003 
   984 	$wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
  1004 	$wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
  1239 			}
  1259 			}
  1240 		}
  1260 		}
  1241 
  1261 
  1242 		// If we don't have enough free space, it isn't worth trying again.
  1262 		// If we don't have enough free space, it isn't worth trying again.
  1243 		// Unlikely to be hit due to the check in unzip_file().
  1263 		// Unlikely to be hit due to the check in unzip_file().
  1244 		$available_space = @disk_free_space( ABSPATH );
  1264 		$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( ABSPATH ) : false;
  1245 
  1265 
  1246 		if ( $available_space && $total_size >= $available_space ) {
  1266 		if ( $available_space && $total_size >= $available_space ) {
  1247 			$result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ) );
  1267 			$result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ) );
  1248 		} else {
  1268 		} else {
  1249 			$result = _copy_dir( $from . $distro, $to, $skip );
  1269 			$result = _copy_dir( $from . $distro, $to, $skip );
  1395 	_upgrade_422_remove_genericons();
  1415 	_upgrade_422_remove_genericons();
  1396 
  1416 
  1397 	// Deactivate the REST API plugin if its version is 2.0 Beta 4 or lower.
  1417 	// Deactivate the REST API plugin if its version is 2.0 Beta 4 or lower.
  1398 	_upgrade_440_force_deactivate_incompatible_plugins();
  1418 	_upgrade_440_force_deactivate_incompatible_plugins();
  1399 
  1419 
  1400 	// Deactivate the Gutenberg plugin if its version is 10.7 or lower.
  1420 	// Deactivate the Gutenberg plugin if its version is 11.8 or lower.
  1401 	_upgrade_580_force_deactivate_incompatible_plugins();
  1421 	_upgrade_590_force_deactivate_incompatible_plugins();
  1402 
  1422 
  1403 	// Upgrade DB with separate request.
  1423 	// Upgrade DB with separate request.
  1404 	/** This filter is documented in wp-admin/includes/update-core.php */
  1424 	/** This filter is documented in wp-admin/includes/update-core.php */
  1405 	apply_filters( 'update_feedback', __( 'Upgrading database…' ) );
  1425 	apply_filters( 'update_feedback', __( 'Upgrading database…' ) );
  1406 
  1426 
  1534  * This function is only needed when the existing installation is older than 3.4.0.
  1554  * This function is only needed when the existing installation is older than 3.4.0.
  1535  *
  1555  *
  1536  * @since 3.3.0
  1556  * @since 3.3.0
  1537  *
  1557  *
  1538  * @global string $wp_version The WordPress version string.
  1558  * @global string $wp_version The WordPress version string.
  1539  * @global string $pagenow
  1559  * @global string $pagenow    The filename of the current screen.
  1540  * @global string $action
  1560  * @global string $action
  1541  *
  1561  *
  1542  * @param string $new_version
  1562  * @param string $new_version
  1543  */
  1563  */
  1544 function _redirect_to_about_wordpress( $new_version ) {
  1564 function _redirect_to_about_wordpress( $new_version ) {
  1654 	) {
  1674 	) {
  1655 		$files[] = "{$directory}example.html";
  1675 		$files[] = "{$directory}example.html";
  1656 	}
  1676 	}
  1657 
  1677 
  1658 	$dirs = glob( $directory . '*', GLOB_ONLYDIR );
  1678 	$dirs = glob( $directory . '*', GLOB_ONLYDIR );
       
  1679 	$dirs = array_filter(
       
  1680 		$dirs,
       
  1681 		static function( $dir ) {
       
  1682 			// Skip any node_modules directories.
       
  1683 			return false === strpos( $dir, 'node_modules' );
       
  1684 		}
       
  1685 	);
  1659 
  1686 
  1660 	if ( $dirs ) {
  1687 	if ( $dirs ) {
  1661 		foreach ( $dirs as $dir ) {
  1688 		foreach ( $dirs as $dir ) {
  1662 			$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
  1689 			$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
  1663 		}
  1690 		}
  1675 		deactivate_plugins( array( 'rest-api/plugin.php' ), true );
  1702 		deactivate_plugins( array( 'rest-api/plugin.php' ), true );
  1676 	}
  1703 	}
  1677 }
  1704 }
  1678 
  1705 
  1679 /**
  1706 /**
       
  1707  * @access private
  1680  * @ignore
  1708  * @ignore
  1681  * @since 5.8.0
  1709  * @since 5.9.0
  1682  */
  1710  */
  1683 function _upgrade_580_force_deactivate_incompatible_plugins() {
  1711 function _upgrade_590_force_deactivate_incompatible_plugins() {
  1684 	if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '10.7', '<=' ) ) {
  1712 	if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '11.9', '<' ) ) {
  1685 		$deactivated_gutenberg['gutenberg'] = array(
  1713 		$deactivated_gutenberg['gutenberg'] = array(
  1686 			'plugin_name'         => 'Gutenberg',
  1714 			'plugin_name'         => 'Gutenberg',
  1687 			'version_deactivated' => GUTENBERG_VERSION,
  1715 			'version_deactivated' => GUTENBERG_VERSION,
  1688 			'version_compatible'  => '10.8',
  1716 			'version_compatible'  => '11.9',
  1689 		);
  1717 		);
  1690 		if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
  1718 		if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
  1691 			$deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );
  1719 			$deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );
  1692 			$deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
  1720 			$deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
  1693 			update_site_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
  1721 			update_site_option( 'wp_force_deactivated_plugins', $deactivated_plugins );