Project

General

Profile

Actions

Bug #103946

open

DefaultUploadFolderResolver: error for user specific file mount

Added by Philipp Gollmer 6 months ago. Updated 5 months ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Backend User Interface
Target version:
-
Start date:
2024-05-28
Due date:
% Done:

0%

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

Description

Short description:
DefaultUploadFolderResolver->resolve() throws error, when f.e. default page folder is “user_upload”, but specific backend user has not “user_upload” as filemount.

Long description:

Scenario:
Page default upload folder is “fileadmin/user_upload”
Backend user has only file_mountpoint “fileadmin/user_upload/a/b/c”

I want as this backend user edit an record inside the list-module which has files as field properties.

Problem:
typo3/cms-core/Classes/Resource/DefaultUploadFolderResolver.php

public function resolve(BackendUserAuthentication $user, int $pid = null, string $table = null, string $field = null): Folder | bool
    {
        $uploadFolder = $this->getDefaultUploadFolderForUser($user);
        $uploadFolder = $this->getDefaultUploadFolderForPage($pid) ?? $uploadFolder;

        $uploadFolder = $this->eventDispatcher->dispatch(
            new AfterDefaultUploadFolderWasResolvedEvent($uploadFolder, $pid, $table, $field)
        )->getUploadFolder() ?? $uploadFolder;

        $uploadFolder = $uploadFolder ?? $this->getDefaultUploadFolder($user);

        return $uploadFolder instanceof Folder ? $uploadFolder : false;
    }

The first line in this function returns correct folder for “fileadmin/user_upload/a/b/c”.
In the second line it tries to get the default folder from the page (“fileadmin/user_upload”), BUT the function getDefaultUploadFolderForPage() at the same time checks permissions and throws error, because the user has correctly not the permission, but it wrongly throws error at this place.

In my opinion the next wrong thing is, that the second line gives the standard page folder a higher weighting than the user-specific folder. It should be the other way around.

The first line set correct folder “fileadmin/user_upload/a/b/c” and in this scenario this should be the correct return value.


Files

Actions

Also available in: Atom PDF