Bug #88895

Auto-creates wrong folders if groupHomePath is used.

Added by Stig Nørgaard Færch 15 days ago. Updated 5 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Form Framework
Start date:
2019-08-02
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
CodingNight
Complexity:
easy
Is Regression:
Sprint Focus:

Description

I have this configuration, which is dynamically set from a hook:
module.tx_form.settings.yamlSettingsOverrides.persistenceManager.allowedFileMounts.1 =1:groups/{uid}/forms/

We are using the userGroupHomePath core feature. Here you can define a path - for example 1:groups/. Then if you are member of backendgroup with uid 200, you will automatically get a mount to 1:groups/200/ if that folders exists.

I have a problem when ext:form tries to create the folder. Instead of 1:groups/200/forms it created this path instead: 1:groups/200/groups/200/forms

The reason seems to be when \TYPO3\CMS\Core\Resource\ResourceStorage::createFolder tries to get the parentFolder - instead of getting just 1: - it gets 1:/groups/200 - probably as the user does not have access to parent folders (because of the way userGroupHome works).
That way it creates 1:/groups/200/ + groups/200/forms/ instead.

History

#1 Updated by Stig Nørgaard Færch 15 days ago

I have made this fix.
I'm not in the loop on how this is done the right way, as we seldom contribute this way...
Hope someone can help me getting this fixed...

/Stig

Index: public/typo3/sysext/form/Classes/Mvc/Persistence/FormPersistenceManager.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- public/typo3/sysext/form/Classes/Mvc/Persistence/FormPersistenceManager.php    (date 1564755837000)
+++ public/typo3/sysext/form/Classes/Mvc/Persistence/FormPersistenceManager.php    (date 1564755837000)
@@ -459,7 +459,13 @@
             try {
                 $folder = $storage->getFolder($fileMountIdentifier);
             } catch (FolderDoesNotExistException $e) {
-                $storage->createFolder($fileMountIdentifier);
+                //Fix to make sure that the folder is create correctly when using groupHomePath https://forge.typo3.org/issues/88895
+                if(strpos(str_replace(':/',':', $storage->getRootLevelFolder()->getCombinedIdentifier()), $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath']) === 0) {
+                    $groupHomeFolder = $storage->getRootLevelFolder();
+                    $groupHomeFolder->createFolder(str_replace($storage->getRootLevelFolder()->getIdentifier(),'', '/'. $fileMountIdentifier));
+                } else {
+                    $storage->createFolder($fileMountIdentifier);
+                }
                 continue;
             } catch (InsufficientFolderAccessPermissionsException $e) {
                 continue;

#2 Updated by Susanne Moog 15 days ago

  • Tags set to CodingNight

#3 Updated by Stig Nørgaard Færch 5 days ago

@susanne.moog
When does this Coding Night take place?

Also available in: Atom PDF