Project

General

Profile

Actions

Bug #103153

closed

Wrong behaviour of $storage->hasFile($identifier)

Added by Tee Ohh 9 months ago. Updated 9 months ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
Start date:
2024-02-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

System environment

I have a docker container with Ubuntu on a Windows 10 maschine for development. The file system is shared between Ubuntu and Windows.

TYPO3 setup

The local fileadmin storage has an enabled "Uses case sensitive identifiers" checkbox.
I can create case sensitive file names in the TYPO3 backend without problems.
If I use the function $storage->hasFile($identifier) from the default storage to check if a file is available and the identifier is in lower case (example.txt), but the file name is upper case (Example.text), the function returns true. This is wrong. In the same time an additional sys_file record is created with a lower case identifier and a lower case file name. That is also wrong.

Steps to reproduce

1. Create a file in the file list with the name "Example.text".
2. Check the sys_file record: Identifier: "/Example.txt", name: "Example.txt"
3. Execute the following script:

<?php
declare(strict_types = 1);

namespace Vendor\MyExtension;

use TYPO3\CMS\Core\Resource\StorageRepository;

class ExampleClass
{
    protected StorageRepository $storageRepository;

    /**
     * Constructor
     * 
     * @param StorageRepository $storageRepository
     */
    public function __construct(StorageRepository $storageRepository) {
        $this->storageRepository = $storageRepository;
    }

    /**
     * Example function
     */
    public function exampleFunction()
    {
        // Get storage
        $storage = $this->storageRepository->getDefaultStorage();

        // Check file
        $result = $storage->hasFile('example.txt');

        // Debug
        debug($result, 'example.txt is available?');
    }
}

4. The debug result is true and a second sys_file record exists: Identifier: "/example.txt", name: "example.txt". But in the file system only Example.txt exists.

The function should return false and also creating not a second sys_file record with wrong data.

Actions

Also available in: Atom PDF