Bug #90063
closedGeneralUtility::writeFileToTypo3tempDir returns always an error even if the file is written
100%
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.
Files
Updated by Gerrit Code Review over 4 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62828
Updated by Gerrit Code Review over 4 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62828
Updated by Gerrit Code Review over 4 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62828
Updated by Gerrit Code Review over 4 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62828
Updated by Anja Leichsenring over 4 years ago
- Status changed from Under Review to Rejected
the use case described can not be realized anymore with the function. The error report could not be verified.
Closed by request of author.
Updated by Rémy DANIEL over 4 years ago
I requested the close of this issue and the associated review because the usecase I had changed.
But, I reproduce the error described above with this simple lines of code, on TYPO3 9.5, in composer mode:
if (\TYPO3\CMS\Core\Core\Environment::isComposerMode()) {
$filename = \TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/test.txt';
$error = \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($filename, 'foo');
var_dump(file_exists($filename)); // true
var_dump($error); // "/var/www/html/web/typo3temp/" was not within directory ProjectPath + var
@unlink($filename);
}
There is 3 places in the core where the error could rise (using GU::writeFileToTypo3tempDir()
to write in the public/typo3temp
dir).
Fortunately the return of GU::writeFileToTypo3tempDir() is not tested there.
GeneralUtility::writeJavaScriptContentToTemporaryFile() GeneralUtility::writeStyleSheetContentToTemporaryFile() \TYPO3\CMS\Frontend\Page\PageGenerator::inline2TempFile()
Also, I would argue that GU::writeFileToTypo3tempDir()
is not a good name anymore.
The method should be called GU::writeFileToVarDir()
.
Cheers.
Updated by Lina Wolf almost 4 years ago
I can reproduce the error, cost me several hours of debugging. I get the error in 9.5.21 in Extension https://github.com/sabbelasichon/bzga_beratungsstellensuche when importing data containing images
Attached patch fixed it for me.
Updated by Marieke de Bruin over 3 years ago
I can reproduce this issue on 10.4.14, please reopen this issue.
Updated by Gerrit Code Review over 3 years ago
- Status changed from Rejected to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68721
Updated by Gerrit Code Review over 3 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68721
Updated by Gerrit Code Review over 3 years ago
Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68868
Updated by Riny van Tiggelen over 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset a0bcdc259a6a40884caa72d12087a947e176bf4a.