[TASK] Install Tool: Allow multiple permission status per file 79/24179/2
authorErnesto Baschny <ernst@cron-it.de>
Mon, 30 Sep 2013 18:13:39 +0000 (20:13 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 1 Oct 2013 16:27:05 +0000 (18:27 +0200)
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
typo3/sysext/install/Classes/FolderStructure/DirectoryNode.php
typo3/sysext/install/Classes/FolderStructure/FileNode.php
typo3/sysext/install/Classes/FolderStructure/RootNode.php

index 3775f66..19dc5b9 100644 (file)
@@ -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;
        }
index ea6bbbb..176d7ae 100644 (file)
@@ -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;
        }
index 65d34cf..a62e2e8 100644 (file)
@@ -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;