Project

General

Profile

Actions

Bug #90063

closed

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

Added by Rémy DANIEL over 4 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2020-01-07
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

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

Actions #1

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

Actions #2

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

Actions #3

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

Actions #4

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

Actions #5

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.

Actions #6

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.

Actions #7

Updated by Lina Wolf over 3 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.

Actions #8

Updated by Marieke de Bruin about 3 years ago

I can reproduce this issue on 10.4.14, please reopen this issue.

Actions #9

Updated by Gerrit Code Review about 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

Actions #10

Updated by Gerrit Code Review almost 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

Actions #11

Updated by Gerrit Code Review almost 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

Actions #12

Updated by Riny van Tiggelen almost 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #13

Updated by Benni Mack almost 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF