Issue Bug Closed

#90063GeneralUtility::writeFileToTypo3tempDir returns always an error even if the file is written

Rémy DANIEL 01/07/20, 10:42 updated 05/11/21, 15:59

Description

TYPO3 9 + composer mode

The above code returns always an error, but the file is correctly created:

$filepath = '/var/www/html/web/typo3temp/var/tx_static404/foo.txt';
$error = \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($filepath, 'foo');

// $error contains '"/var/www/html/web/typo3temp/var/tx_static404/" was not within directory ProjectPath + var' instead of NULL

The issue is that writeFileToTypo3tempDir checks if the directory of the file is within two allowed pathes:
- Environment::getPublicPath() + “/typo3temp/“
- Environment::getVarPath()

But even if the file is written in the within the first path, the second path is still checked.

The foreach should break as soon as the file is successfully created, and returns NULL error message, as expected.

Reviews 3