Bug #100911
closedCustom MenuProcessor creates kind of singleton
100%
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.
Updated by Oliver Bartsch over 1 year 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.
Updated by Oliver Bartsch over 1 year ago
- Related to Task #96005: Add aliases for DataProcessors added
Updated by Gerrit Code Review over 1 year 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
Updated by Philipp Schlosser over 1 year ago
Yep, seems to fix my problems. Thanks for your quick response.
Updated by Gerrit Code Review over 1 year 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
Updated by Gerrit Code Review over 1 year 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
Updated by Oliver Bartsch over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 1cbb68e562cf42a41455fe88cfdda807aa2ca9e6.