Ticket #18201: 18201.7.diff
| File 18201.7.diff, 10.2 KB (added by , 13 years ago) |
|---|
-
wp-admin/includes/class-wp-upgrader.php
1042 1042 1043 1043 $wp_dir = trailingslashit($wp_filesystem->abspath()); 1044 1044 1045 // Pre-cache the checksums for the versions we care about 1046 get_core_checksums( array( $wp_version, $current->current ) ); /* TODO for 3.7, change this to $current->version */ 1047 1048 $no_partial = false; 1049 apply_filters('update_feedback', __( 'Verifying existing files…' ) ); 1050 if ( ! $this->check_files() ) 1051 $no_partial = true; 1052 1045 1053 // If partial update is returned from the API, use that, unless we're doing a reinstall. 1046 1054 // If we cross the new_bundled version number, then use the new_bundled zip. 1047 1055 // Don't though if the constant is set to skip bundled items. 1048 1056 // If the API returns a no_content zip, go with it. Finally, default to the full zip. 1049 if ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version )1057 if ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && ! $no_partial ) 1050 1058 $to_download = 'partial'; 1051 1059 elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) 1052 1060 && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) … … 1065 1073 return $working_dir; 1066 1074 1067 1075 // Copy update-core.php from the new version into place. 1076 /* // TESTING use existing upgrade-core file 1068 1077 if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) { 1069 1078 $wp_filesystem->delete($working_dir, true); 1070 1079 return new WP_Error('copy_failed', $this->strings['copy_failed']); 1071 1080 } 1072 1081 $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE); 1073 1082 */ 1074 1083 require(ABSPATH . 'wp-admin/includes/update-core.php'); 1075 1084 1076 1085 if ( ! function_exists( 'update_core' ) ) … … 1081 1090 return $result; 1082 1091 } 1083 1092 1093 function check_files() { 1094 global $wp_version; 1095 1096 $checksums = get_core_checksums( $wp_version ); 1097 var_dump([ __METHOD__, $wp_version ]); 1098 if ( empty( $checksums[ $wp_version ] ) || ! is_array( $checksums[ $wp_version ] ) ) 1099 return false; 1100 1101 foreach ( $checksums[ $wp_version ] as $file => $checksum ) { 1102 if ( md5_file( ABSPATH . $file ) !== $checksum ) 1103 return false; 1104 } 1105 1106 return true; 1107 } 1084 1108 } 1085 1109 1086 1110 /** -
wp-admin/includes/update-core.php
683 683 684 684 apply_filters('update_feedback', __('Installing the latest version…')); 685 685 686 // Check to see which files don't really need updating 687 $skip = array( 'wp-content' ); 688 $checksums = get_core_checksums( $wp_version ); /* TODO This function won't exist when upgrading from pre-3.7, which will cause a fatal (This file is included from the new package, and runs with the old versions code) */ 689 if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) { 690 apply_filters('update_feedback', __( 'Determining which files need copying…' ) ); /* TODO language */ 691 foreach( $checksums[ $wp_version ] as $file => $checksum ) { 692 if ( md5_file( ABSPATH . $file ) === $checksum ) 693 $skip[] = $file; 694 } 695 } 696 697 apply_filters('update_feedback', __( 'Enabling Maintainence Mode…' ) ); /* TODO language */ 698 686 699 // Create maintenance file to signal that we are upgrading 687 700 $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; 688 701 $maintenance_file = $to . '.maintenance'; 689 702 $wp_filesystem->delete($maintenance_file); 690 703 $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); 691 704 705 apply_filters('update_feedback', __( 'Copying the required files…' ) ); /* TODO language */ 692 706 // Copy new versions of WP files into place. 693 $result = _copy_dir($from . $distro, $to, array('wp-content'));707 $result = _copy_dir($from . $distro, $to, $skip ); 694 708 709 // Check to make sure everything copied correctly 710 $skip = array( 'wp-content' ); 711 $failed = array(); 712 if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) { 713 foreach( $checksums[ $wp_version ] as $file => $checksum ) { 714 if ( md5_file( ABSPATH . $file ) === $checksum ) 715 $skip[] = $file; 716 else 717 $failed[] = $file; 718 } 719 } 720 721 // Some files didn't copy properly 722 if ( ! empty( $failed ) ) { 723 $total_size = 0; 724 foreach ( $failed as $file ) 725 $total_size += filesize( $from . '/' . $distro . '/' . $file ); /* TODO This won't work with FTP The $from contains a dynamic name so WP_CONTENT_DIR can't be used directly */ 726 727 // If we don't have enough free space, it isn't worth trying again 728 if ( $total_size >= disk_free_space( ABSPATH ) ) 729 $result = new WP_Error( 'disk_full', __( "There isn't enough free disk space to complete the upgrade." ), $to ); 730 else 731 $result = _copy_dir( $from . $distro, $to, $skip ); 732 } 733 695 734 // Custom Content Directory needs updating now. 696 735 // Copy Languages 697 736 if ( !is_wp_error($result) && $wp_filesystem->is_dir($from . $distro . 'wp-content/languages') ) { … … 788 827 else 789 828 delete_option('update_core'); 790 829 830 apply_filters('update_feedback', __( 'Disabling Maintainence mode…' ) ); /* TODO language */ 791 831 // Remove maintenance file, we're done. 792 832 $wp_filesystem->delete($maintenance_file); 793 833 794 834 // If we made it this far: 795 do_action( '_core_updated_successfully', $wp_version );835 //do_action( '_core_updated_successfully', $wp_version ); 796 836 797 837 return $wp_version; 798 838 } … … 801 841 * Copies a directory from one location to another via the WordPress Filesystem Abstraction. 802 842 * Assumes that WP_Filesystem() has already been called and setup. 803 843 * 804 * This is a temporary function for the 3.1 -> 3.2 upgrade only and will be removed in 3.3805 *806 844 * @ignore 807 845 * @since 3.2.0 846 * @since 3.7.0 Updated not to use a regular expression for the skip list 808 847 * @see copy_dir() 809 848 * 810 849 * @param string $from source directory … … 820 859 $from = trailingslashit($from); 821 860 $to = trailingslashit($to); 822 861 823 $skip_regex = ''; 824 foreach ( (array)$skip_list as $key => $skip_file ) 825 $skip_regex .= preg_quote($skip_file, '!') . '|'; 862 /* The regex form doesn't like long $skip_list's, nor does it deal well with */ 863 $skip_string = implode( ',', $skip_list ) . ',update-core.php'; /* TODO remove hard-coded file */ 826 864 827 if ( !empty($skip_regex) )828 $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';829 830 865 foreach ( (array) $dirlist as $filename => $fileinfo ) { 831 if ( !empty($skip_regex) ) 832 if ( preg_match($skip_regex, $from . $filename) ) 833 continue; 866 // if ( $skip_list && false !== stripos( $skip_string, $filename ) ) /* TODO This skip functionality doesn't work either. all sub directories fail to copy, ie. wp-includes IS in 'wp-includes/some/file.php,wp-content/whatever' */ 867 // continue; 834 868 835 869 if ( 'f' == $fileinfo['type'] ) { 836 870 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { … … 883 917 show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), $new_version, 'about.php?updated' ) . '</span>' ); 884 918 show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, 'about.php?updated' ) . '</span>' ); 885 919 echo '</div>'; 920 return; 921 886 922 ?> 887 923 <script type="text/javascript"> 888 924 window.location = 'about.php?updated'; … … 893 929 include(ABSPATH . 'wp-admin/admin-footer.php'); 894 930 exit(); 895 931 } 896 add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); 932 // add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); /* TESTING I want to see the upgrade result! */ -
wp-admin/includes/update.php
56 56 return $result; 57 57 } 58 58 59 /** 60 * Gets and caches the checksums for the given versions of WordPress 61 * 62 * @since 3.7.0 63 * 64 * @param $version string|array A single version, or an array of versions to fetch 65 * 66 * @return bool|array False on failure, otherwise the array of checksums, keyed by version 67 */ 68 69 70 function get_core_checksums( $version ) { 71 if ( ! is_array( $version ) ) 72 $version = array( $version ); 73 var_dump( $version ); 74 $return = array(); 75 76 // Check to see if we have cached copies available, if we do, no need to request them 77 foreach ( $version as $i => $v ) { 78 if ( $checksums = get_site_transient( "core_checksums_$v" ) ) { 79 unset( $version[ $i ] ); 80 $return[ $v ] = $checksums; 81 } 82 } 83 84 // We had cached copies for all of the versions! 85 if ( empty( $version ) ) 86 return $return; 87 88 $url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( array( 'version' => $version ), null, '&' ); 89 90 if ( wp_http_supports( array( 'ssl' ) ) ) 91 $url = set_url_scheme( $url, 'https' ); 92 93 $options = array( 94 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), 95 ); 96 97 $response = wp_remote_get( $url, $options ); 98 99 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) 100 return false; 101 102 $body = trim( wp_remote_retrieve_body( $response ) ); 103 $body = json_decode( $body, true ); 104 105 if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) 106 return false; 107 108 // Cache the checksums for later 109 foreach ( $version as $v ) { 110 set_site_transient( "core_checksums_$v", $body['checksums'][ $v ], HOUR_IN_SECONDS ); 111 $return[ $v ] = $body['checksums'][ $v ]; 112 } 113 114 // If the API didn't return anything for a version, explicitly set it's return value to false 115 foreach ( $return as $v => $r ) { 116 if ( empty( $r ) ) 117 $return[ $v ] = false; 118 } 119 120 return $return; 121 } 122 59 123 function dismiss_core_update( $update ) { 60 124 $dismissed = get_site_option( 'dismissed_update_core' ); 61 125 $dismissed[ $update->current.'|'.$update->locale ] = true;
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)