141a142
> 		$this->strings['working_dir_filepath_too_long'] = __('Working directory path length is too long.');
282,284c283,305
< 
< 		// We need a working directory - Strip off any .tmp or .zip suffixes
< 		$working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
---
> 		
> 		//Strip off any .tmp or .zip suffixes from temporary package filename
> 		$tmp_filename_no_suffix = basename( basename( $package, '.tmp' ), '.zip' );
> 
> 		// We need a working directory
> 		$working_dir = $upgrade_folder . $tmp_filename_no_suffix;
> 		
> 		/* Filepaths should be 255 characters or fewer to prevent errors on Windows installations.
> 		If working directory path is longer than 255 characters then try to remove some
> 		characters from the temporary directory name to bring it within 255 characters. */
> 		$how_much_too_long = strlen($working_dir)-255;
> 		
> 		if ($how_much_too_long > 0) {
> 			$tmp_filename_no_suffix_length = strlen($tmp_filename_no_suffix);
> 			/* If the length by which the working directory filepath is too long is greater
> 			than or equal to the length of the temporary directory's name then throw an error
> 			as we will not be able to create a short enough working directory path. */
> 			if ($how_much_too_long >= $tmp_filename_no_suffix_length) {
> 				return new WP_Error( 'working_dir_filepath_too_long', $this->strings['working_dir_filepath_too_long'] );
> 			}
> 			$shortened_directory_name = substr($tmp_filename_no_suffix, 0, $tmp_filename_no_suffix_length-$how_much_too_long);
> 			$working_dir = $upgrade_folder . $shortened_directory_name;
> 		}
