Index: class-wp-upgrader.php
===================================================================
--- class-wp-upgrader.php	(revision 36863)
+++ class-wp-upgrader.php	(working copy)
@@ -139,6 +139,7 @@
 		$this->strings['no_files'] = __('The package contains no files.');
 		$this->strings['folder_exists'] = __('Destination folder already exists.');
 		$this->strings['mkdir_failed'] = __('Could not create directory.');
+		$this->strings['working_dir_filepath_too_long'] = __('Working directory path length is too long.');
 		$this->strings['incompatible_archive'] = __('The package could not be installed.');
 		$this->strings['files_not_writable'] = __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' );
 
@@ -280,9 +281,29 @@
 				$wp_filesystem->delete($upgrade_folder . $file['name'], true);
 		}
 
-		// 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.
+		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;
+		}
+
 		// Clean up working directory
 		if ( $wp_filesystem->is_dir($working_dir) )
 			$wp_filesystem->delete($working_dir, true);
