Project

General

Profile

Actions

Bug #64113

closed

GeneralUtility::writeFile() fails if directory not existing

Added by Boris Günther almost 10 years ago. Updated almost 10 years ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-01-04
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Hello TYPO3-Team,

I found a possible bug in \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile();.

Problem:

The method does not check if the parent directory exists and therefore gets an error when trying to fopen() the file.

Solution:

Adding this snippet at beginning of the method fixes the problem:

// Create the folder if missing
if(!is_dir(dirname($file))) {
    //Get creation mask
    $targetDirectoryPermissions = isset($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']) ? octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']) : octdec('0755');

    //Create folder
    if(mkdir(dirname($file), 0777, true) !== true) {
        return FALSE;
    }
}

Reproducibility:

The error occurs only when updating extension languages against a custom translation server.

Environment:

PHP: 5.5.14
TYPO3: 6.2.9


Files

trb_tool_translation-l10n-de.zip (474 Bytes) trb_tool_translation-l10n-de.zip Boris Günther, 2015-01-04 19:23
Actions

Also available in: Atom PDF