Changeset 25540 for trunk/src/wp-admin/includes/update-core.php
- Timestamp:
- 09/21/2013 06:48:20 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/update-core.php
r25307 r25540 689 689 return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) ); 690 690 691 apply_filters('update_feedback', __('Installing the latest version…')); 692 691 apply_filters( 'update_feedback', __( 'Preparing to install the latest version…' ) ); 692 693 // Don't copy wp-content, we'll deal with that below 694 $skip = array( 'wp-content' ); 695 696 // Check to see which files don't really need updating - only available for 3.7 and higher 697 if ( function_exists( 'get_core_checksums' ) ) { 698 $checksums = get_core_checksums( $wp_version ); 699 if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) { 700 foreach( $checksums[ $wp_version ] as $file => $checksum ) { 701 if ( md5_file( ABSPATH . $file ) === $checksum ) 702 $skip[] = $file; 703 } 704 } 705 } 706 707 apply_filters( 'update_feedback', __( 'Enabling Maintenance mode…' ) ); 693 708 // Create maintenance file to signal that we are upgrading 694 709 $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; … … 697 712 $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); 698 713 714 apply_filters( 'update_feedback', __( 'Copying the required files…' ) ); 699 715 // Copy new versions of WP files into place. 700 $result = _copy_dir($from . $distro, $to, array('wp-content') ); 716 $result = _copy_dir( $from . $distro, $to, $skip ); 717 718 // Check to make sure everything copied correctly, ignoring the contents of wp-content 719 $skip = array( 'wp-content' ); 720 $failed = array(); 721 if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) { 722 foreach ( $checksums[ $wp_version ] as $file => $checksum ) { 723 if ( 0 === strpos( $file, 'wp-content' ) ) 724 continue; 725 726 if ( md5_file( ABSPATH . $file ) == $checksum ) 727 $skip[] = $file; 728 else 729 $failed[] = $file; 730 } 731 } 732 733 // Some files didn't copy properly 734 if ( ! empty( $failed ) ) { 735 $total_size = 0; 736 // Find the local version of the working directory 737 $working_dir_local = str_replace( trailingslashit( $wp_filesystem->wp_content_dir() ), trailingslashit( WP_CONTENT_DIR ), $from . $distro ); 738 foreach ( $failed as $file ) 739 $total_size += filesize( $working_dir_local . '/' . $file ); 740 741 // If we don't have enough free space, it isn't worth trying again 742 if ( $total_size >= disk_free_space( ABSPATH ) ) 743 $result = new WP_Error( 'disk_full', __( "There isn't enough free disk space to complete the upgrade." ), $to ); 744 else 745 $result = _copy_dir( $from . $distro, $to, $skip ); 746 } 701 747 702 748 // Custom Content Directory needs updating now. … … 796 842 delete_option('update_core'); 797 843 844 apply_filters( 'update_feedback', __( 'Disabling Maintenance mode…' ) ); 798 845 // Remove maintenance file, we're done. 799 846 $wp_filesystem->delete($maintenance_file); … … 809 856 * Assumes that WP_Filesystem() has already been called and setup. 810 857 * 811 * This is a temporary function for the 3.1 -> 3.2 upgrade only and will be removed in 3.3 858 * This is a temporary function for the 3.1 -> 3.2 upgrade, as well as for those upgrading to 859 * 3.7+ 812 860 * 813 861 * @ignore 814 862 * @since 3.2.0 863 * @since 3.7.0 Updated not to use a regular expression for the skip list 815 864 * @see copy_dir() 816 865 * … … 828 877 $to = trailingslashit($to); 829 878 830 $skip_regex = '';831 foreach ( (array)$skip_list as $key => $skip_file )832 $skip_regex .= preg_quote($skip_file, '!') . '|';833 834 if ( !empty($skip_regex) )835 $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';836 837 879 foreach ( (array) $dirlist as $filename => $fileinfo ) { 838 if ( !empty($skip_regex) ) 839 if ( preg_match($skip_regex, $from . $filename) ) 840 continue; 880 if ( in_array( $filename, $skip_list ) ) 881 continue; 841 882 842 883 if ( 'f' == $fileinfo['type'] ) { … … 852 893 return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename); 853 894 } 854 $result = _copy_dir($from . $filename, $to . $filename, $skip_list); 895 896 // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list 897 $sub_skip_list = array(); 898 foreach ( $skip_list as $skip_item ) { 899 if ( 0 === strpos( $skip_item, $filename . '/' ) ) 900 $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); 901 } 902 903 $result = _copy_dir($from . $filename, $to . $filename, $sub_skip_list); 855 904 if ( is_wp_error($result) ) 856 905 return $result;
Note: See TracChangeset
for help on using the changeset viewer.