Project

General

Profile

Actions

Bug #100911

closed

Custom MenuProcessor creates kind of singleton

Added by Philipp Schlosser 12 months ago. Updated 12 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2023-05-23
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If you implement a custom MenuProcessor, for every new menuProcessor you define in typoscript, the same instance will be used.

for example

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        dataProcessing {
            10 = MyVendor\MyExtension\DataProcessing\CustomMenuProcessor
            10 {
                special = directory
                special.value = 10 # should show every child page from page 10
                as = menuOne
            }
            20 = MyVendor\MyExtension\DataProcessing\CustomMenuProcessor
            20 {
                special = directory
                special.value = 20 # should show every child page from page 20
                as = menuTwo
            }
        }
    }
}

In this example "menuOne" should contain every child page from page 10. "menuTwo" should container every child page from page 20 but does contain pages from 10.

Another example:
Use TS Config from above and implement a counter property in your custom MenuProcessor.

namespace MyVendor\MyExtension\DataProcessing;

class CustomMenuProcessor implements \TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface {
    protected $counter = 0;
    /**
     * @param ContentObjectRenderer $cObj
     * @param array $contentObjectConfiguration
     * @param array $processorConfiguration
     * @param array $processedData
     * @return array
     */
    public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData): array
    {
        $this->counter ++;
        \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->counter);
        return $processedData;
    }
}

The example above should print 1 and 1, but does 1 and 2.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #96005: Add aliases for DataProcessorsClosed2021-11-16

Actions
Actions #1

Updated by Oliver Bartsch 12 months ago

  • Status changed from New to Needs Feedback

Hi,

thanks for creating this issue. Could you please share the registration of your custom data processor (usually done in your extensions Services.yaml). It might be that you did not set the shared: false tag attribute.

Actions #2

Updated by Oliver Bartsch 12 months ago

  • Related to Task #96005: Add aliases for DataProcessors added
Actions #3

Updated by Gerrit Code Review 12 months ago

  • Status changed from Needs Feedback to Under Review

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

Actions #4

Updated by Philipp Schlosser 12 months ago

Yep, seems to fix my problems. Thanks for your quick response.

Actions #5

Updated by Gerrit Code Review 12 months ago

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

Actions #6

Updated by Gerrit Code Review 12 months ago

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

Actions #7

Updated by Oliver Bartsch 12 months ago

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

Also available in: Atom PDF