--- /home/vagrant/.wordpresses/latest/wp-admin/includes/class-wp-filesystem-direct.php	2015-09-10 02:21:24.000000000 +0100
+++ pragmatic/wp-admin/includes/class-wp-filesystem-direct.php	2017-07-05 17:53:32.106480089 +0100
@@ -297,8 +297,9 @@
 			return false;
 		$file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
 
-		if ( 'f' == $type || $this->is_file($file) )
-			return @unlink($file);
+		if ( 'f' == $type || $this->is_file($file) || $this->is_link($file) )
+			// rtrim() needed to remove symlinks successfully.
+			return @unlink(rtrim($file, '/'));
 		if ( ! $recursive && $this->is_dir($file) )
 			return @rmdir($file);
 
@@ -340,6 +341,16 @@
 	/**
 	 * @access public
 	 *
+	 * @param string $file
+	 * @return bool
+	 */
+	public function is_link($file) {
+		// Strip trailing slashes, to avoid directory symlinks resolving.
+		return @is_link(rtrim($file, '/'));
+	}
+	/**
+	 * @access public
+	 *
 	 * @param string $path
 	 * @return bool
 	 */
@@ -461,7 +472,10 @@
 	 * @return bool|array
 	 */
 	public function dirlist($path, $include_hidden = true, $recursive = false) {
-		if ( $this->is_file($path) ) {
+		if ( $this->is_dir($path) && $this->is_link($path) ) {
+			// Directory is symlink, therefore return no listing.
+			return array();
+		} elseif ( $this->is_file($path) || $this->is_link($path) ) {
 			$limit_file = basename($path);
 			$path = dirname($path);
 		} else {
@@ -501,7 +515,7 @@
 			$struc['time']    	= date('h:i:s',$struc['lastmodunix']);
 			$struc['type']		= $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
 
-			if ( 'd' == $struc['type'] ) {
+			if ( 'd' == $struc['type'] && !$this->is_link($path . '/' . $struc['name']) ) {
 				if ( $recursive )
 					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
 				else
--- /home/vagrant/.wordpresses/latest/wp-admin/includes/class-wp-upgrader.php	2016-09-18 21:16:29.000000000 +0100
+++ pragmatic/wp-admin/includes/class-wp-upgrader.php	2017-07-05 17:51:54.272281914 +0100
@@ -377,7 +377,9 @@
 
 				// Attempt to alter permissions to allow writes and try again.
 				$wp_filesystem->chmod( $remote_destination . $filename, ( 'd' == $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) );
-				if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
+				// is_writable() returns false on symlinks for some reason.
+				if ( ! $wp_filesystem->is_writable( $remote_destination . $filename )
+					 && ! $wp_filesystem->is_link( $remote_destination . $filename ) ) {
 					$unwritable_files[] = $filename;
 				}
 			}
