Changeset 47122 for trunk/src/wp-admin/includes/class-wp-upgrader.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r46823 r47122 196 196 $error = $wp_filesystem->errors; 197 197 } 198 // Failed to connect , Error and request again198 // Failed to connect. Error and request again. 199 199 $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership ); 200 200 return false; … … 239 239 } 240 240 return true; 241 } //end fs_connect();241 } 242 242 243 243 /** … … 268 268 } 269 269 270 if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { // Local file or remote?271 return $package; // must be a local file..270 if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { // Local file or remote? 271 return $package; // Must be a local file. 272 272 } 273 273 … … 306 306 $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/'; 307 307 308 // Clean up contents of upgrade directory beforehand.308 // Clean up contents of upgrade directory beforehand. 309 309 $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder ); 310 310 if ( ! empty( $upgrade_files ) ) { … … 314 314 } 315 315 316 // We need a working directory - Strip off any .tmp or .zip suffixes316 // We need a working directory - strip off any .tmp or .zip suffixes. 317 317 $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' ); 318 318 319 // Clean up working directory 319 // Clean up working directory. 320 320 if ( $wp_filesystem->is_dir( $working_dir ) ) { 321 321 $wp_filesystem->delete( $working_dir, true ); 322 322 } 323 323 324 // Unzip package to working directory 324 // Unzip package to working directory. 325 325 $result = unzip_file( $package, $working_dir ); 326 326 … … 357 357 $files[ $path . $name ] = $details; 358 358 359 // Append children recursively 359 // Append children recursively. 360 360 if ( ! empty( $details['files'] ) ) { 361 361 $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' ); 362 362 363 // Merge keeping possible numeric keys, which array_merge() will reindex from 0..n 363 // Merge keeping possible numeric keys, which array_merge() will reindex from 0..n. 364 364 $files = $files + $children; 365 365 } … … 389 389 } 390 390 391 // Flatten the file list to iterate over 391 // Flatten the file list to iterate over. 392 392 $files = $this->flatten_dirlist( $files ); 393 393 … … 451 451 452 452 $defaults = array( 453 'source' => '', // Please always pass this 454 'destination' => '', // and this453 'source' => '', // Please always pass this. 454 'destination' => '', // ...and this. 455 455 'clear_destination' => false, 456 456 'clear_working' => false, … … 491 491 } 492 492 493 // Retain the Original source and destinations493 // Retain the original source and destinations. 494 494 $remote_source = $args['source']; 495 495 $local_destination = $destination; … … 498 498 $remote_destination = $wp_filesystem->find_folder( $local_destination ); 499 499 500 //Locate which directory to copy to the new folder, This is based on the actual folder holding the files. 501 if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents. 500 // Locate which directory to copy to the new folder. This is based on the actual folder holding the files. 501 if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { 502 // Only one folder? Then we want its contents. 502 503 $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] ); 503 504 } elseif ( count( $source_files ) == 0 ) { 504 return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files? 505 } else { // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename. 505 // There are no files? 506 return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); 507 } else { 508 // It's only a single file, the upgrader will use the folder name of this file as the destination folder. 509 // Folder name is based on zip filename. 506 510 $source = trailingslashit( $args['source'] ); 507 511 } … … 569 573 } 570 574 } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) { 571 // If we're not clearing the destination folder and something exists there already, Bail.572 // But first check to see if there are actually any files in the folder.575 // If we're not clearing the destination folder and something exists there already, bail. 576 // But first check to see if there are actually any files in the folder. 573 577 $_files = $wp_filesystem->dirlist( $remote_destination ); 574 578 if ( ! empty( $_files ) ) { 575 $wp_filesystem->delete( $remote_source, true ); // Clear out the source files.579 $wp_filesystem->delete( $remote_source, true ); // Clear out the source files. 576 580 return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination ); 577 581 } 578 582 } 579 583 580 // Create destination if needed584 // Create destination if needed. 581 585 if ( ! $wp_filesystem->exists( $remote_destination ) ) { 582 586 if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) { … … 584 588 } 585 589 } 590 586 591 // Copy new version of item into place. 587 592 $result = copy_dir( $source, $remote_destination ); … … 593 598 } 594 599 595 // Clear the Working folder?600 // Clear the working folder? 596 601 if ( $args['clear_working'] ) { 597 602 $wp_filesystem->delete( $remote_source, true ); … … 621 626 } 622 627 623 // Bombard the calling function will all the info which we've just used.628 // Bombard the calling function will all the info which we've just used. 624 629 return $this->result; 625 630 } … … 662 667 $defaults = array( 663 668 'package' => '', // Please always pass this. 664 'destination' => '', // And this669 'destination' => '', // ...and this. 665 670 'clear_destination' => false, 666 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please671 'abort_if_destination_exists' => true, // Abort if the destination directory exists. Pass clear_destination as false please. 667 672 'clear_working' => true, 668 673 'is_multi' => false, … … 704 709 $options = apply_filters( 'upgrader_package_options', $options ); 705 710 706 if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times711 if ( ! $options['is_multi'] ) { // Call $this->header separately if running multiple times. 707 712 $this->skin->header(); 708 713 } 709 714 710 // Connect to the Filesystem first.715 // Connect to the filesystem first. 711 716 $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) ); 712 717 // Mainly for non-connected filesystem. … … 741 746 // Don't output the 'no signature could be found' failure message for now. 742 747 if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) { 743 // Out out the failure error as a normal feedback, and not as an error:748 // Output the failure error as a normal feedback, and not as an error. 744 749 $this->skin->feedback( $download->get_error_message() ); 745 750 … … 766 771 } 767 772 768 $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file 773 $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file. 769 774 770 775 // Unzips the file into a temporary directory. … … 858 863 if ( $enable ) { 859 864 $this->skin->feedback( 'maintenance_start' ); 860 // Create maintenance file to signal that we are upgrading 865 // Create maintenance file to signal that we are upgrading. 861 866 $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; 862 867 $wp_filesystem->delete( $file );
Note: See TracChangeset
for help on using the changeset viewer.