Make WordPress Core


Ignore:
Timestamp:
11/13/2008 06:48:54 PM (16 years ago)
Author:
ryan
Message:

Revert [9523]. fixes #8195 see #7395

File:
1 edited

Legend:

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

    r9593 r9664  
    247247
    248248    apply_filters('update_feedback', __('Installing the latest version'));
    249 
     249    // Copy new version of plugin into place.
     250    $result = copy_dir($working_dir, $plugins_dir);
     251    if ( is_wp_error($result) ) {
     252        $wp_filesystem->delete($working_dir, true);
     253        return $result;
     254    }
     255
     256    //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
    250257    $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
    251 
    252     //find base plugin directory
    253     $res = update_pluginfiles_base_dir($working_dir . '/' . $filelist[0], $plugins_dir . $filelist[0]);
    254 
    255     //Create folder if not exists.
    256     if( ! $wp_filesystem->exists( $res['to'] ) )
    257         if ( ! $wp_filesystem->mkdir( $res['to'], 0755 ) )
    258             return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']); 
    259 
    260     // Copy new version of plugin into place.
    261     $result = copy_dir($res['from'], $res['to']);
    262     if ( is_wp_error($result) ) {
    263         $wp_filesystem->delete($working_dir, true);
    264         return $result;
    265     }
    266258
    267259    // Remove working directory
     
    271263    delete_option('update_plugins');
    272264
    273     $folder = trailingslashit(str_replace($plugins_dir, '', $res['to']));
     265    if( empty($filelist) )
     266        return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
     267
     268    $folder = $filelist[0];
    274269    $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
    275270    $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
    276271
    277     //Return the plugin files name.
    278     return $folder . $pluginfiles[0];
     272    return  $folder . '/' . $pluginfiles[0];
    279273}
    280274
Note: See TracChangeset for help on using the changeset viewer.