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 #1

Updated by Andreas Kienast 9 months ago · Edited

  • Status changed from New to Needs Feedback

Can you please explain your system? Do you use WSL? Who is the host of the filesystem? If Windows is the host, I think there's not much we can do here as the underlying NTFS is case-insensitive.

Actions #2

Updated by Tee Ohh 9 months ago

I do NOT use a WSL based engine for Docker. Maybe the host of the file system is Windows. I don't know it. Hopefully the docker-compose.yml file helps. I see in Windows Exploer all the files and folders starting from /var/www/html/.

version: "3.7" 

services:

  redis:
    container_name: ${COMPOSE_PROJECT_NAME}_redis
    image: ${REDIS_IMAGE:-redis:alpine}
    environment:
      - REDIS_REPLICATION_MODE=${REDIS_REPLICATION_MODE:-master}
    volumes:
      - redis:/var/lib/redis
    ports:
      - ${REDIS_PORT:-6219}:6379
    command: redis-server --requirepass ${REDIS_ROOT_PASSWORD:-********}

  db:
    container_name: ${COMPOSE_PROJECT_NAME}_db
    image: ${DB_IMAGE:-mariadb:10.5}
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-********}
    volumes:
      - db:/var/lib/mysql
    ports:
      - ${DB_PORT:-6019}:3306
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --sql_mode=NO_ENGINE_SUBSTITUTION

  web:
    container_name: ${COMPOSE_PROJECT_NAME}_web
    build:
      context: ${WEB_IMAGE:-https://git.********}
      args:
        TYPO3_WEB_DIR: ${TYPO3_WEB_DIR}
    depends_on:
      - db
      - redis
    environment:
      - VIRTUAL_HOST=${COMPOSE_PROJECT_HOST}
      - TYPO3_CONTEXT=${TYPO3_CONTEXT:-Development/local}
      - TYPO3_ADMIN_USER=${TYPO3_ADMIN_USER:-admin}
      - TYPO3_ADMIN_PASSWORD=${TYPO3_ADMIN_PASSWORD:-********}

      - DB_HOST=${COMPOSE_PROJECT_NAME}_db
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-********}
      - DB_NAME=${DB_NAME:-typo3}
      - DB_USER=${DB_USER:-root}

      - USER_ID=${USER_ID:-1000}

      - COMPOSER_AUTH=${COMPOSER_AUTH}
    healthcheck:
      disable: true
    volumes:
      - ../:/var/www/html${FILE_SYSTEM_MODE:-:delegated}

networks:
  default:
    name: webproxy
    external: true

volumes:
  db:
    name: ${COMPOSE_PROJECT_NAME}_db
  redis:
    name: ${COMPOSE_PROJECT_NAME}_redis

Actions #3

Updated by Benjamin Franzke 9 months ago

  • Status changed from Needs Feedback to Rejected

Thanks for the docker-composer and the additional information.

You are using a native Windows folder (case-insensitive) and mount that into docker. As docker has to relay all files to the host filesystem, that means the file system will also behave case-insensitive (although being masked as being something like ext2, it is not) and that means you must not configure "Uses case sensitive identifiers" in that case, since you are using a case-insensitive filesystem.

Please change the configuration of your TYPO3 file storage or even better (I guess you copied this system from a linux server), write the files to a native WSL storage (not /mnt/c, but sth like /home/…) and run docker from WSL/with WSL engine.

Actions

Also available in: Atom PDF