Bug #103946
openDefaultUploadFolderResolver: error for user specific file mount
0%
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
Updated by Georg Ringer 2 months ago
- Status changed from New to Needs Feedback
IMO this is correct in this order as the getDefaultUploadFolderForPage
can be changed per page and the other one is globally.
but what about catching the error in the 2nd one and use the 1st then if error happens?
Updated by Philipp Gollmer 2 months ago
That would solve all the current issues here, yes.
Updated by Georg Ringer 2 months ago
I took a look and my setup in v13 is the following:
editor with a filemount to 1:user_upload/subuser_upload
and the user can just upload files and no error at all.
can you try to reproduce that on a v13?
Updated by Philipp Gollmer about 2 months ago
I have found out that the error only appears with the implementation of the following PageTs setting.
options.defaultUploadFolder = 1:/user_upload/
The behavior in TYPO3 12 and 13 is identical.
With this setting: Error described above. Without this setting: Works.
I think that this is not a bug at all, but that I have to make sure in the configuration that the settings are consistent. Normally, the setting "options.defaultUploadFolder = 1:/user_upload/" is not necessary at all.