Issue Bug Closed

#103728fixPermission() throws exception if permissions are correct

Hartmut Müller 04/25/24, 19:15 updated 07/09/24, 15:35

Description

The function fixPermission() in typo3/sysext/install/Classes/FolderStructure/AbstractNode.php throws an exception if permissions are equal to the target permissions:

if ($this->isPermissionCorrect()) {
    throw new Exception(
        'Permission on ' . $this->getAbsolutePath() . ' are already ok',
        1366744035
    );
}
$result = @chmod($this->getAbsolutePath(), (int)octdec($this->getTargetPermission()));
…

The exception is used as a program control structure here. The side effect is that any cli script calling this function returns an error code on absolutely correct permissions.

composer install calls implicitly install:fixfolderstructure, which calls fixPermission().

Our auto-deployment fails if all file and directory permissions are correct.

I would expect that fixPermission() would throw an exception on uncorrectable permissions only.

The behaviour is documented here [[https://docs.typo3.org/typo3cms/exceptions/main/en-us/Exceptions/1366744035.html]], but the resolution to ignore this error is not the best solution in scripted deployments.

Reviews 2