WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/11/2013 04:05:13 PM (6 years ago)
Author:
nacin
Message:

Refine error codes throughout the upgrader so we can better detect at what stage updates fail.

see #22704.

File:
1 edited

Legend:

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

    r25739 r25763  
    604604    for ( $i = 0; $i < $z->numFiles; $i++ ) {
    605605        if ( ! $info = $z->statIndex($i) )
    606             return new WP_Error('stat_failed', __('Could not retrieve file from archive.'));
     606            return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
    607607
    608608        if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
     
    634634    foreach ( $needed_dirs as $_dir ) {
    635635        if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the Dir exists upon creation failure. Less I/O this way.
    636             return new WP_Error('mkdir_failed', __('Could not create directory.'), $_dir);
     636            return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), $_dir );
    637637    }
    638638    unset($needed_dirs);
     
    640640    for ( $i = 0; $i < $z->numFiles; $i++ ) {
    641641        if ( ! $info = $z->statIndex($i) )
    642             return new WP_Error('stat_failed', __('Could not retrieve file from archive.'));
     642            return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
    643643
    644644        if ( '/' == substr($info['name'], -1) ) // directory
     
    650650        $contents = $z->getFromIndex($i);
    651651        if ( false === $contents )
    652             return new WP_Error('extract_failed', __('Could not extract file from archive.'), $info['name']);
     652            return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
    653653
    654654        if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
    655             return new WP_Error('copy_failed', __('Could not copy file.'), $to . $info['name']);
     655            return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $to . $info['name'] );
    656656    }
    657657
     
    692692
    693693    if ( 0 == count($archive_files) )
    694         return new WP_Error('empty_archive', __('Empty archive.'));
     694        return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
    695695
    696696    // Determine any children directories needed (From within the archive)
     
    721721    foreach ( $needed_dirs as $_dir ) {
    722722        if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the dir exists upon creation failure. Less I/O this way.
    723             return new WP_Error('mkdir_failed', __('Could not create directory.'), $_dir);
     723            return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), $_dir );
    724724    }
    725725    unset($needed_dirs);
     
    734734
    735735        if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
    736             return new WP_Error('copy_failed', __('Could not copy file.'), $to . $file['filename']);
     736            return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $to . $file['filename'] );
    737737    }
    738738    return true;
     
    767767                $wp_filesystem->chmod($to . $filename, 0644);
    768768                if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
    769                     return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
     769                    return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
    770770            }
    771771        } elseif ( 'd' == $fileinfo['type'] ) {
    772772            if ( !$wp_filesystem->is_dir($to . $filename) ) {
    773773                if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
    774                     return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
     774                    return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
    775775            }
    776776
Note: See TracChangeset for help on using the changeset viewer.