Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r46823 r47122  
    196196                $error = $wp_filesystem->errors;
    197197            }
    198             // Failed to connect, Error and request again
     198            // Failed to connect. Error and request again.
    199199            $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership );
    200200            return false;
     
    239239        }
    240240        return true;
    241     } //end fs_connect();
     241    }
    242242
    243243    /**
     
    268268        }
    269269
    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.
    272272        }
    273273
     
    306306        $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
    307307
    308         //Clean up contents of upgrade directory beforehand.
     308        // Clean up contents of upgrade directory beforehand.
    309309        $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
    310310        if ( ! empty( $upgrade_files ) ) {
     
    314314        }
    315315
    316         // We need a working directory - Strip off any .tmp or .zip suffixes
     316        // We need a working directory - strip off any .tmp or .zip suffixes.
    317317        $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
    318318
    319         // Clean up working directory
     319        // Clean up working directory.
    320320        if ( $wp_filesystem->is_dir( $working_dir ) ) {
    321321            $wp_filesystem->delete( $working_dir, true );
    322322        }
    323323
    324         // Unzip package to working directory
     324        // Unzip package to working directory.
    325325        $result = unzip_file( $package, $working_dir );
    326326
     
    357357            $files[ $path . $name ] = $details;
    358358
    359             // Append children recursively
     359            // Append children recursively.
    360360            if ( ! empty( $details['files'] ) ) {
    361361                $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' );
    362362
    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.
    364364                $files = $files + $children;
    365365            }
     
    389389        }
    390390
    391         // Flatten the file list to iterate over
     391        // Flatten the file list to iterate over.
    392392        $files = $this->flatten_dirlist( $files );
    393393
     
    451451
    452452        $defaults = array(
    453             'source'                      => '', // Please always pass this
    454             'destination'                 => '', // and this
     453            'source'                      => '', // Please always pass this.
     454            'destination'                 => '', // ...and this.
    455455            'clear_destination'           => false,
    456456            'clear_working'               => false,
     
    491491        }
    492492
    493         //Retain the Original source and destinations
     493        // Retain the original source and destinations.
    494494        $remote_source     = $args['source'];
    495495        $local_destination = $destination;
     
    498498        $remote_destination = $wp_filesystem->find_folder( $local_destination );
    499499
    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.
    502503            $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
    503504        } 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.
    506510            $source = trailingslashit( $args['source'] );
    507511        }
     
    569573            }
    570574        } 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.
    573577            $_files = $wp_filesystem->dirlist( $remote_destination );
    574578            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.
    576580                return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
    577581            }
    578582        }
    579583
    580         //Create destination if needed
     584        // Create destination if needed.
    581585        if ( ! $wp_filesystem->exists( $remote_destination ) ) {
    582586            if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
     
    584588            }
    585589        }
     590
    586591        // Copy new version of item into place.
    587592        $result = copy_dir( $source, $remote_destination );
     
    593598        }
    594599
    595         //Clear the Working folder?
     600        // Clear the working folder?
    596601        if ( $args['clear_working'] ) {
    597602            $wp_filesystem->delete( $remote_source, true );
     
    621626        }
    622627
    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.
    624629        return $this->result;
    625630    }
     
    662667        $defaults = array(
    663668            'package'                     => '', // Please always pass this.
    664             'destination'                 => '', // And this
     669            'destination'                 => '', // ...and this.
    665670            'clear_destination'           => false,
    666             'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please
     671            'abort_if_destination_exists' => true, // Abort if the destination directory exists. Pass clear_destination as false please.
    667672            'clear_working'               => true,
    668673            'is_multi'                    => false,
     
    704709        $options = apply_filters( 'upgrader_package_options', $options );
    705710
    706         if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times
     711        if ( ! $options['is_multi'] ) { // Call $this->header separately if running multiple times.
    707712            $this->skin->header();
    708713        }
    709714
    710         // Connect to the Filesystem first.
     715        // Connect to the filesystem first.
    711716        $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
    712717        // Mainly for non-connected filesystem.
     
    741746            // Don't output the 'no signature could be found' failure message for now.
    742747            if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) {
    743                 // Outout 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.
    744749                $this->skin->feedback( $download->get_error_message() );
    745750
     
    766771        }
    767772
    768         $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file
     773        $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file.
    769774
    770775        // Unzips the file into a temporary directory.
     
    858863        if ( $enable ) {
    859864            $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.
    861866            $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
    862867            $wp_filesystem->delete( $file );
Note: See TracChangeset for help on using the changeset viewer.