Skip to content

Commit 8c54945

Browse files
Bugfix fix indexing of nested gridelements with data processing lib
1 parent 1b4e4d6 commit 8c54945

File tree

2 files changed

+72
-20
lines changed

2 files changed

+72
-20
lines changed

Documentation/Changelog/Index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
12.0.8
5+
-----
6+
7+
- Fix indexing of nested gridelements with data processing lib content element
8+
49
12.0.7
510
-----
611

indexer/ttcontent/class.tx_mksearch_indexer_ttcontent_Gridelements.php

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* This copyright notice MUST APPEAR in all copies of the script!
2424
***************************************************************/
2525

26+
use Psr\Http\Message\ServerRequestInterface;
27+
2628
/**
2729
* Gridelements indexer.
2830
*
@@ -148,13 +150,42 @@ protected function getGridelementElementContent(
148150
array $record,
149151
array $options
150152
) {
151-
$pageIdOfRecord = $record['pid'];
153+
$pageIdOfRecord = (int) $record['pid'];
152154
tx_mksearch_util_Indexer::prepareTSFE($pageIdOfRecord, $options['lang'] ?? 0);
153155

154-
$allowedCTypes = $this->getAllowedCTypes($options);
155-
156156
/** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
157157
$cObj = $GLOBALS['TSFE']->cObj;
158+
$setup = $this->getTypoScriptConfiguration($cObj, $options, $pageIdOfRecord);
159+
160+
// This is needed so the BackendConfigurationManager loads the TypoScript for the current tt_content
161+
// record during it's rendering and not for the page that is selected in the BE page tree.
162+
if (\Sys25\RnBase\Utility\TYPO3::isTYPO121OrHigher()) {
163+
$originalRequest = $cObj->getRequest();
164+
$originalPageId = null;
165+
} else {
166+
$originalPageId = $_POST['id'] ?? null;
167+
$originalRequest = null;
168+
}
169+
$this->populatePageIdOfRecord($cObj, $pageIdOfRecord);
170+
171+
$cObj->start($record, 'tt_content');
172+
173+
$content = $cObj->cObjGetSingle(
174+
$setup['tt_content.']['gridelements_pi1'],
175+
$setup['tt_content.']['gridelements_pi1.']
176+
);
177+
$this->resetPopulatedPageIdOfRecord($originalRequest, $originalPageId);
178+
179+
return $content;
180+
}
181+
182+
protected function getTypoScriptConfiguration(
183+
\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj,
184+
array $options,
185+
int $pageIdOfRecord
186+
): array {
187+
$allowedCTypes = $this->getAllowedCTypes($options);
188+
158189
$setup = \Sys25\RnBase\Utility\TYPO3::isTYPO121OrHigher()
159190
? $cObj->getRequest()->getAttribute('frontend.typoscript')->getSetupArray()
160191
: $GLOBALS['TSFE']->tmpl->setup;
@@ -183,40 +214,56 @@ protected function getGridelementElementContent(
183214
$frontendTypoScript->setSetupArray($setup);
184215
$cObj->setRequest($cObj->getRequest()->withAttribute('frontend.typoscript', $frontendTypoScript));
185216
}
217+
218+
// Put in runtime cache for TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager so
219+
// includeCTypesInGridelementRendering is available at this point
220+
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache(
221+
'runtime'
222+
)->set('extbase-backend-typoscript-pageId-'.$pageIdOfRecord, $setup);
186223
}
187224

188-
// This is needed so the BackendConfigurationManager loads the TypoScript for the current tt_content
189-
// record during it's rendering and not for the page that is selected in the BE page tree.
225+
return $setup;
226+
}
227+
228+
/**
229+
* This is needed so the BackendConfigurationManager loads the TypoScript for the current tt_content
230+
* record during it's rendering and not for the page that is selected in the BE page tree.
231+
*/
232+
protected function populatePageIdOfRecord(
233+
\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj,
234+
int $pageIdOfRecord
235+
): void {
190236
if (\Sys25\RnBase\Utility\TYPO3::isTYPO121OrHigher()) {
191-
$originalRequest = $cObj->getRequest();
192237
$configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
193238
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class
194239
);
195-
$configurationManager->setRequest($originalRequest->withParsedBody(array_merge(
196-
$originalRequest->getParsedBody() ?? [],
240+
$configurationManager->setRequest($cObj->getRequest()->withParsedBody(array_merge(
241+
$cObj->getRequest()->getParsedBody() ?? [],
197242
['id' => $pageIdOfRecord]
198243
)));
199244
} else {
200-
$originalPageId = $_POST['id'] ?? null;
201245
$_POST['id'] = $pageIdOfRecord;
202246
}
247+
}
203248

204-
$cObj->start($record, 'tt_content');
205-
206-
$content = $cObj->cObjGetSingle(
207-
$setup['tt_content.']['gridelements_pi1'],
208-
$setup['tt_content.']['gridelements_pi1.']
209-
);
249+
/**
250+
* Make sure to reset the request/id so the configuration manager will load the TypoScript for the page that is
251+
* selected in the BE page tree if it's needed after this point.
252+
*/
253+
protected function resetPopulatedPageIdOfRecord(
254+
?ServerRequestInterface $originalRequest,
255+
?int $originalPageId
256+
): void {
210257
// Make sure to reset the request/id so the configuration manager will load the TypoScript for the page that is
211258
// selected in the BE page tree if it's needed after this point.
212-
if (isset($originalRequest) && isset($configurationManager)) {
259+
if (\Sys25\RnBase\Utility\TYPO3::isTYPO121OrHigher()) {
260+
$configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
261+
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class
262+
);
213263
$configurationManager->setRequest($originalRequest);
214-
}
215-
if (isset($originalPageId)) {
264+
} else {
216265
$_POST['id'] = $originalPageId;
217266
}
218-
219-
return $content;
220267
}
221268

222269
/**

0 commit comments

Comments
 (0)