From e605c495cc72b33e4b4261e93c3fd4423327c536 Mon Sep 17 00:00:00 2001
From: Ernesto Baschny <ernst@cron-it.de>
Date: Mon, 30 Sep 2013 20:13:39 +0200
Subject: [PATCH] [TASK] Install Tool: Allow multiple permission status per
 file

Sometimes a file has incorrect content and incorrect permissions.
Now both warnings are shown at the same time.

Resolves: #52405
Releases: 6.2
Change-Id: I8c36db5f42456ef9491dc1329dc7e0b22b815395
Reviewed-on: https://review.typo3.org/24179
Reviewed-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
---
 .../Classes/FolderStructure/DirectoryNode.php | 16 ++++++++--------
 .../Classes/FolderStructure/FileNode.php      | 19 ++++++++++---------
 .../Classes/FolderStructure/RootNode.php      |  2 +-
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/typo3/sysext/install/Classes/FolderStructure/DirectoryNode.php b/typo3/sysext/install/Classes/FolderStructure/DirectoryNode.php
index 3775f66a9224..19dc5b9c7712 100644
--- a/typo3/sysext/install/Classes/FolderStructure/DirectoryNode.php
+++ b/typo3/sysext/install/Classes/FolderStructure/DirectoryNode.php
@@ -82,7 +82,7 @@ class DirectoryNode extends AbstractNode implements NodeInterface {
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' does not exist');
 			$result[] = $status;
 		} else {
-			$result[] = $this->getSelfStatus();
+			$result = $this->getSelfStatus();
 		}
 		$result = array_merge($result, $this->getChildrenStatus());
 		return $result;
@@ -180,10 +180,10 @@ class DirectoryNode extends AbstractNode implements NodeInterface {
 	/**
 	 * Get status of directory - used in root and directory node
 	 *
-	 * @return \TYPO3\CMS\Install\Status\StatusInterface
+	 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
 	 */
 	protected function getSelfStatus() {
-		$result = NULL;
+		$result = array();
 		if (!$this->isDirectory()) {
 			$status = new Status\ErrorStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' is not a directory');
@@ -191,7 +191,7 @@ class DirectoryNode extends AbstractNode implements NodeInterface {
 				'Path ' . $this->getAbsolutePath() . ' should be a directory,' .
 				' but is of type ' . filetype($this->getAbsolutePath())
 			);
-			$result = $status;
+			$result[] = $status;
 		} elseif (!$this->isWritable()) {
 			$status = new Status\ErrorStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' is not writable');
@@ -199,7 +199,7 @@ class DirectoryNode extends AbstractNode implements NodeInterface {
 				'Path ' . $this->getAbsolutePath() . ' exists, but no file below' .
 				' can be created.'
 			);
-			$result = $status;
+			$result[] = $status;
 		} elseif (!$this->isPermissionCorrect()) {
 			if ($this->getTargetPermissionRelaxed() === TRUE) {
 				$status = new Status\NoticeStatus();
@@ -208,7 +208,7 @@ class DirectoryNode extends AbstractNode implements NodeInterface {
 					'Target permission are ' . $this->targetPermission .
 					' but current permission are ' . $this->getCurrentPermission()
 				);
-				$result = $status;
+				$result[] = $status;
 			} else {
 				$status = new Status\WarningStatus();
 				$status->setTitle($this->getRelativePathBelowSiteRoot() . ' has wrong permission');
@@ -216,12 +216,12 @@ class DirectoryNode extends AbstractNode implements NodeInterface {
 					'Target permission are ' . $this->targetPermission .
 					' but current permission are ' . $this->getCurrentPermission()
 				);
-				$result = $status;
+				$result[] = $status;
 			}
 		} else {
 			$status = new Status\OkStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot());
-			$result = $status;
+			$result[] = $status;
 		}
 		return $result;
 	}
diff --git a/typo3/sysext/install/Classes/FolderStructure/FileNode.php b/typo3/sysext/install/Classes/FolderStructure/FileNode.php
index ea6bbbbd552f..176d7aece802 100644
--- a/typo3/sysext/install/Classes/FolderStructure/FileNode.php
+++ b/typo3/sysext/install/Classes/FolderStructure/FileNode.php
@@ -105,7 +105,7 @@ class FileNode extends AbstractNode implements NodeInterface {
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' does not exist');
 			$result[] = $status;
 		} else {
-			$result[] = $this->getSelfStatus();
+			$result = $this->getSelfStatus();
 		}
 		return $result;
 	}
@@ -189,10 +189,10 @@ class FileNode extends AbstractNode implements NodeInterface {
 	/**
 	 * Get status of file
 	 *
-	 * @return \TYPO3\CMS\Install\Status\StatusInterface
+	 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
 	 */
 	protected function getSelfStatus() {
-		$result = NULL;
+		$result = array();
 		if (!$this->isFile()) {
 			$status = new Status\ErrorStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' is not a file');
@@ -200,7 +200,7 @@ class FileNode extends AbstractNode implements NodeInterface {
 				'Path ' . $this->getAbsolutePath() . ' should be a file,' .
 				' but is of type ' . filetype($this->getAbsolutePath())
 			);
-			$result = $status;
+			$result[] = $status;
 		} elseif (!$this->isWritable()) {
 			$status = new Status\WarningStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' is not writable');
@@ -208,7 +208,7 @@ class FileNode extends AbstractNode implements NodeInterface {
 				'Path ' . $this->getAbsolutePath() . ' exists, but no file below' .
 				' can be created.'
 			);
-			$result = $status;
+			$result[] = $status;
 		} elseif (!$this->isPermissionCorrect()) {
 			$status = new Status\WarningStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' has wrong permission');
@@ -216,19 +216,20 @@ class FileNode extends AbstractNode implements NodeInterface {
 				'Target permission are ' . $this->targetPermission .
 				' but current permission are ' . $this->getCurrentPermission()
 			);
-			$result = $status;
-		} elseif (!$this->isContentCorrect()) {
+			$result[] = $status;
+		}
+		if ($this->isFile() && !$this->isContentCorrect()) {
 			$status = new Status\ErrorStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot() . ' content differs');
 			$status->setMessage(
 				'File content is not identical to target content. Probably, this file was' .
 				' changed manually. The content will not be fixed to not override your changes.'
 			);
-			$result = $status;
+			$result[] = $status;
 		} else {
 			$status = new Status\OkStatus();
 			$status->setTitle($this->getRelativePathBelowSiteRoot());
-			$result = $status;
+			$result[] = $status;
 		}
 		return $result;
 	}
diff --git a/typo3/sysext/install/Classes/FolderStructure/RootNode.php b/typo3/sysext/install/Classes/FolderStructure/RootNode.php
index 65d34cff6397..a62e2e8fbbcb 100644
--- a/typo3/sysext/install/Classes/FolderStructure/RootNode.php
+++ b/typo3/sysext/install/Classes/FolderStructure/RootNode.php
@@ -83,7 +83,7 @@ class RootNode extends DirectoryNode implements RootNodeInterface {
 			$status->setTitle($this->getAbsolutePath() . ' does not exist');
 			$result[] = $status;
 		} else {
-			$result[] = $this->getSelfStatus();
+			$result = $this->getSelfStatus();
 		}
 		$result = array_merge($result, $this->getChildrenStatus());
 		return $result;
-- 
GitLab