WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/19/2010 10:59:32 AM (10 years ago)
Author:
dd32
Message:

Fallback to PclZip in the event that ZipArchive cannot handle a given archive properly. Close the Zip handle when we're done as well. Fixes #12230

File:
1 edited

Legend:

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

    r13025 r13221  
    529529    }
    530530
    531     if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) )
    532         return _unzip_file_ziparchive($file, $to, $needed_dirs);
    533     else
    534         return _unzip_file_pclzip($file, $to, $needed_dirs);
     531    if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) ) {
     532        $result = _unzip_file_ziparchive($file, $to, $needed_dirs);
     533        if ( true === $result ) {
     534            return $result;
     535        } elseif ( is_wp_error($result) ) {
     536            if ( 'incompatible_archive' != $result->get_error_code() )
     537                return $result;
     538        }
     539        echo "fall through to pcl";
     540    }
     541    // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
     542    return _unzip_file_pclzip($file, $to, $needed_dirs);
    535543}
    536544
     
    591599            return new WP_Error('copy_failed', __('Could not copy file.'), $to . $file['filename']);
    592600    }
     601
     602    $z->close();
    593603
    594604    return true;
Note: See TracChangeset for help on using the changeset viewer.