Ticket #20074: 20074.diff
File 20074.diff, 5.1 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/file.php
492 492 * 493 493 * @param string $url the URL of the file to download 494 494 * @param int $timeout The timeout for the request to download the file default 300 seconds 495 * @return mixed WP_Error on failure, string Filename on success. 495 * @param bool $full_response Whether to return the full response instead of just the filename 496 * @return mixed WP_Error on failure, string Filename or HTTP API response array on success. 496 497 */ 497 function download_url( $url, $timeout = 300 ) {498 function download_url( $url, $timeout = 300, $full_response = false ) { 498 499 //WARNING: The file is not automatically deleted, The script must unlink() the file. 499 500 if ( ! $url ) 500 501 return new WP_Error('http_no_url', __('Invalid URL Provided.')); … … 515 516 return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) ); 516 517 } 517 518 518 return $tmpfname; 519 if ( $full_response ) 520 return $response; 521 else 522 return $tmpfname; 519 523 } 520 524 521 525 /** -
wp-admin/includes/class-wp-upgrader.php
49 49 $this->strings['fs_no_folder'] = __('Unable to locate needed folder (%s).'); 50 50 51 51 $this->strings['download_failed'] = __('Download failed.'); 52 $this->strings['download_verification_failed'] = __('Unable to verify download.'); 52 53 $this->strings['installing_package'] = __('Installing the latest version…'); 53 54 $this->strings['folder_exists'] = __('Destination folder already exists.'); 54 55 $this->strings['mkdir_failed'] = __('Could not create directory.'); … … 115 116 116 117 $this->skin->feedback('downloading_package', $package); 117 118 118 $ download_file = download_url($package);119 $response = download_url($package, 300, true); 119 120 120 if ( is_wp_error($ download_file) )121 return new WP_Error('download_failed', $this->strings['download_failed'], $ download_file->get_error_message());121 if ( is_wp_error($response) ) 122 return new WP_Error('download_failed', $this->strings['download_failed'], $response->get_error_message()); 122 123 124 $download_file = $response['filename']; 125 126 $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); 127 128 if ( ! empty( $content_md5 ) ) { 129 $this->skin->feedback('verifying_package'); 130 $md5_file = md5_file( $download_file ); 131 if ( $md5_file != $content_md5 ) 132 return new WP_Error('download_verification_failed', $this->strings['download_verification_failed'], sprintf( __( 'The checksum of the download (%1$s) does not match the provided checksum value (%2$s).' ), $md5_file, $content_md5 ) ); 133 } 134 123 135 return $download_file; 124 136 } 125 137 … … 373 385 $this->strings['up_to_date'] = __('The plugin is at the latest version.'); 374 386 $this->strings['no_package'] = __('Update package not available.'); 375 387 $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>…'); 388 $this->strings['verifying_package'] = __('Verifying the update…'); 376 389 $this->strings['unpack_package'] = __('Unpacking the update…'); 377 390 $this->strings['deactivate_plugin'] = __('Deactivating the plugin…'); 378 391 $this->strings['remove_old'] = __('Removing the old version of the plugin…'); … … 384 397 function install_strings() { 385 398 $this->strings['no_package'] = __('Install package not available.'); 386 399 $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…'); 400 $this->strings['verifying_package'] = __('Verifying the install package…'); 387 401 $this->strings['unpack_package'] = __('Unpacking the package…'); 388 402 $this->strings['installing_package'] = __('Installing the plugin…'); 389 403 $this->strings['process_failed'] = __('Plugin install failed.'); … … 648 662 $this->strings['up_to_date'] = __('The theme is at the latest version.'); 649 663 $this->strings['no_package'] = __('Update package not available.'); 650 664 $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>…'); 665 $this->strings['verifying_package'] = __('Verifying the update…'); 651 666 $this->strings['unpack_package'] = __('Unpacking the update…'); 652 667 $this->strings['remove_old'] = __('Removing the old version of the theme…'); 653 668 $this->strings['remove_old_failed'] = __('Could not remove the old theme.'); … … 658 673 function install_strings() { 659 674 $this->strings['no_package'] = __('Install package not available.'); 660 675 $this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…'); 676 $this->strings['verifying_package'] = __('Verifying the install package…'); 661 677 $this->strings['unpack_package'] = __('Unpacking the package…'); 662 678 $this->strings['installing_package'] = __('Installing the theme…'); 663 679 $this->strings['process_failed'] = __('Theme install failed.');