Project

General

Profile

Actions

Bug #81779

closed

SuggestWizardDefaultReceiver overrides pids when pidList is used

Added by Stefan Terborg almost 7 years ago. Updated about 4 years ago.

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

100%

Estimated time:
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.

Actions #1

Updated by Thorsten Reiter over 6 years 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);
         }
Actions #2

Updated by Riccardo De Contardi over 6 years 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!

Actions #3

Updated by Susanne Moog about 6 years ago

  • Category set to FormEngine aka TCEforms
Actions #4

Updated by Georg Ringer about 4 years ago

can be easily tested with a modified TCA of pages and a shortcut page
using

'shortcut' => [
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.shortcut_page',
            'config' => [
                'type' => 'group',
                'internal_type' => 'db',
                'allowed' => 'pages',
                'size' => 1,
                'maxitems' => 1,
                'minitems' => 0,
                'suggestOptions' => [
                    'default' => [
                        'pidList' => '20,13',
                        'depth' => 2
                    ]
                ],
                'default' => 0,
                'behaviour' => [
                    'allowLanguageSynchronization' => true
                ]
            ]
        ],

Actions #5

Updated by Gerrit Code Review about 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63632

Actions #6

Updated by Gerrit Code Review about 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63632

Actions #7

Updated by Gerrit Code Review about 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63632

Actions #8

Updated by Gerrit Code Review about 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63632

Actions #9

Updated by Gerrit Code Review about 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63632

Actions #10

Updated by Gerrit Code Review about 4 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63653

Actions #11

Updated by Georg Ringer about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #12

Updated by Benni Mack about 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF