Bug #100959
openFile storage 'fileadmin' as default storage must be allowed for editors to show other other filemounts in other file storages
0%
Description
I have a separate file storage for the editors. However, this is only displayed if default file storage fileadmin has also been enabled. Otherwise, the error message appears:
You are not allowed to access the given folder: "" | TYPO3\CMS\Core\ResourceException\InsufficientFolderAccessPermissionsException thrown in file /www/htdocs/xxxxxxx/my-domain.de/typo3_src-12.4.1/typo3/sysext/core/Classes/Resource/ResourceStorage.php in line 849. Requested URL: https://my-domain.de/typo3/wizard/record/browse?token=--AnonymizedToken--&mode=file&bparams=%7C%7C%7Cgif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai,svg%7Cdata-72-tt_address-1-image-sys_file_reference
Files
Updated by Robert Hafenried over 1 year ago
I would expect that fileadmin sharing is not necessary since editors are not supposed to work with this file storage.
Updated by Robert Hafenried over 1 year ago
- Target version deleted (
Candidate for patchlevel)
Updated by Julian Wundrak over 1 year ago
We have the same problem in our project. Currently we use this patch:
Index: Classes/ElementBrowser/AbstractResourceBrowser.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Classes/ElementBrowser/AbstractResourceBrowser.php b/Classes/ElementBrowser/AbstractResourceBrowser.php
--- a/Classes/ElementBrowser/AbstractResourceBrowser.php
+++ b/Classes/ElementBrowser/AbstractResourceBrowser.php (date 1688372094488)
@@ -116,9 +116,31 @@
}
if (!$this->selectedFolder) {
- $this->selectedFolder = $resourceFactory->getDefaultStorage()?->getRootLevelFolder() ?? null;
+ $this->selectedFolder = $this->findAccessableRootLevelFolder();
}
}
+
+ private function findAccessableRootLevelFolder(): ?Folder
+ {
+ $storages = [];
+ $storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
+ foreach ($storageRepository->findAll() as $storage) {
+ if ($storage->isDefault()) {
+ \array_unshift($storages, $storage);
+ } else {
+ $storages[] = $storage;
+ }
+ }
+
+ foreach ($storages as $storage) {
+ $rootFolder = $storage->getRootLevelFolder();
+ if ($rootFolder && $rootFolder->checkActionPermission('read')) {
+ return $rootFolder;
+ }
+ }
+
+ return null;
+ }
protected function getViewModeButton(): ButtonInterface
{
I'm sure, that this is not the correct way, but the issue is, that the default-Storage is not accessable for the user by permissions. This patch select the first available folder, if nothing is selected.
Updated by Karsten Nowak (undkonsorten) 7 months ago
We had the same problem here. But unfortunately the patch doesn't help. Error still exists. Fortunately we had only one site in this instance and only one used file storage. So we can set the second storage as default. That's ok for the moment.
But I think that is not a solution for that issue in general. In multisite instances and multiple editors with different access right on filemounts/filestorages it's not possible to give the user only one storage.
Our system: TYPO3 12.4.14, PHP 8.2
Updated by Sybille Peters 3 months ago
- File stacktrace_100959.txt stacktrace_100959.txt added
Robert Hafenried, could you add steps to reproduce to your issue description? Also a full stack trace might help.
Karsten, can you check if the patch works if "Add media file" is used to load files (instead of e.g. using LinkBrowser) - just to confirm?
I (probably) have the same problem:
- other storages (besides fileadmin) are defined
- some editors have only access to other storages, not fileadmin
- after update to v12 editors (with these other file storages) are no longer able to upload files using the file browser or add file links. In the file browser the error message appears: You are not allowed to access the given folder: "" (debugging confirms, TYPO3 is trying to use "fileadmin")
- problem does not occur for admin, only non-admin editors
The problem is pretty severe because was not noticed before upgrade and now editors can't work.
As workaround, I created an additional directory and sys_filemount in fileadmin (readonly) and assigned it to the main editor group. Is a bit ugly because they see this directory and is a bit pointless.
But is workaround and now uploading files works again.
I also had similar patch to JuLian, but it only worked for the part with "Upload file", not in LinkBrowser.
How TYPO3 detects which folder to use seems to be different, depending on how you load files (in v12):
1. Use "Add media file" in "Media" tab of "Text & Media element => AbstractResourceBrowser::initSelectedFolder is used (which calls getDefaultStorage(), this is what is patched in patch by Julian.
2. Use Link Browser, tab "File": ResourceFactory::getDefaultStorage() is called directly
Updated by Sybille Peters 3 months ago
- Related to Bug #104603: The selected directory is not stored in LinkBrowser anymore (since v12) added