From 6026bea73d0dcb9305b402b30d8e4b61cfc29d33 Mon Sep 17 00:00:00 2001 From: Georg Ringer <georg.ringer@gmail.com> Date: Mon, 10 Jun 2024 22:32:06 +0200 Subject: [PATCH] [BUGFIX] Return an OK message if permissions are already fine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the permissions are already ok, better return an OK FlashMessage instead of throwing an exception. Resolves: #103728 Releases: main, 12.4 Change-Id: I280b1de894dcb78bc222ff1f585ff37627408e5c Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84575 Reviewed-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com> Tested-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: core-ci <typo3@b13.com> --- .../install/Classes/FolderStructure/AbstractNode.php | 6 +++--- .../Tests/Unit/FolderStructure/AbstractNodeTest.php | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php b/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php index b8b1a4396596..89ee54f57d4e 100644 --- a/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php +++ b/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php @@ -144,9 +144,9 @@ abstract class AbstractNode protected function fixPermission(): FlashMessage { if ($this->isPermissionCorrect()) { - throw new Exception( - 'Permission on ' . $this->getAbsolutePath() . ' are already ok', - 1366744035 + return new FlashMessage( + '', + 'Permission on ' . $this->getAbsolutePath() . ' is already ok.' ); } $result = @chmod($this->getAbsolutePath(), (int)octdec($this->getTargetPermission())); diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php index 58afce216278..ef6d24b0b11e 100644 --- a/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php +++ b/typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php @@ -23,7 +23,6 @@ use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Install\FolderStructure\AbstractNode; -use TYPO3\CMS\Install\FolderStructure\Exception; use TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException; use TYPO3\CMS\Install\FolderStructure\NodeInterface; use TYPO3\CMS\Install\FolderStructure\RootNodeInterface; @@ -134,7 +133,7 @@ final class AbstractNodeTest extends AbstractFolderStructureTestCase } #[Test] - public function fixPermissionThrowsExceptionIfPermissionAreAlreadyCorrect(): void + public function fixPermissionReturnsOkIfPermissionAreAlreadyCorrect(): void { $node = $this->getAccessibleMock( AbstractNode::class, @@ -143,11 +142,9 @@ final class AbstractNodeTest extends AbstractFolderStructureTestCase '', false ); - $this->expectException(Exception::class); - $this->expectExceptionCode(1366744035); $node->method('getAbsolutePath')->willReturn(''); $node->expects(self::once())->method('isPermissionCorrect')->willReturn(true); - $node->_call('fixPermission'); + self::assertEquals(ContextualFeedbackSeverity::OK, $node->_call('fixPermission')->getSeverity()); } #[Test] -- GitLab