Bug #81779

SuggestWizardDefaultReceiver overrides pids when pidList is used

Added by Stefan Terborg almost 2 years ago. Updated over 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2017-07-04
Due date:
% Done:

0%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The suggest wizard can be configurated to use a list of pids (pidList) to search from. But the array of allowed pids is constructed the wrong way.

This happens in the constructor method in line 116 in combination with method getAllSubpagesOfPage:

111    if (isset($config['pidList'])) {
112        $allowedPages = ($pageIds = GeneralUtility::trimExplode(',', $config['pidList']));
113        $depth = (int)$config['pidDepth'];
114        foreach ($pageIds as $pageId) {
115            if ($pageId > 0) {
116                \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($allowedPages, $this->getAllSubpagesOfPage($pageId, $depth));
117            }
118        }
119        $this->allowedPages = array_unique($allowedPages);
120    }

Example:
pidList = 5,2,3
pidDepth = 0
results in $this->allowedPages: 3,2,3

Reason is that the array of pids has normal integer keys that get overriden when merged. Perhaps the pid array should take the pids as keys.

History

#1 Updated by Thorsten Reiter over 1 year ago

could be fixed as following:

         if (isset($config['pidList'])) {
-            $allowedPages = ($pageIds = GeneralUtility::trimExplode(',', $config['pidList']));
+            $pageIds = GeneralUtility::trimExplode(',', $config['pidList']);
+            $allowedPages = array_flip($pageIds);
             $depth = (int)$config['pidDepth'];
             foreach ($pageIds as $pageId) {
                 if ($pageId > 0) {
-                    \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($allowedPages, $this->getAllSubpagesOfPage($pageId, $depth));
+                    \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($allowedPages, array_flip($this->getAllSubpagesOfPage($pageId, $depth)));
                 }
             }
-            $this->allowedPages = array_unique($allowedPages);
+            $this->allowedPages = array_keys($allowedPages);
         }

#2 Updated by Riccardo De Contardi over 1 year ago

Hi and thank you for your findings. Could you please push a patch to Gerrit (https://review.typo3.org/) ?

See istructions here: https://docs.typo3.org/typo3cms/ContributionWorkflowGuide/ feel free to ask for support on Slack if needed, and thank you again!

#3 Updated by Susanne Moog over 1 year ago

  • Category set to FormEngine aka TCEforms

Also available in: Atom PDF