[!!!][TASK] Migrate Extbase Query Parser to Doctrine DBAL
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Storage / Typo3DbBackend.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic\Storage;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Doctrine\DBAL\DBALException;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Database\ConnectionPool;
20 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
21 use TYPO3\CMS\Core\SingletonInterface;
22 use TYPO3\CMS\Core\Utility\GeneralUtility;
23 use TYPO3\CMS\Core\Utility\MathUtility;
24 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
25 use TYPO3\CMS\Extbase\DomainObject\AbstractValueObject;
26 use TYPO3\CMS\Extbase\Persistence\Generic\Qom;
27 use TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException;
28 use TYPO3\CMS\Extbase\Persistence\QueryInterface;
29
30 /**
31 * A Storage backend
32 */
33 class Typo3DbBackend implements BackendInterface, SingletonInterface
34 {
35 /**
36 * The TYPO3 database object
37 *
38 * @var \TYPO3\CMS\Core\Database\DatabaseConnection
39 */
40 protected $databaseHandle;
41
42 /**
43 * @var ConnectionPool
44 */
45 protected $connectionPool;
46
47 /**
48 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper
49 */
50 protected $dataMapper;
51
52 /**
53 * The TYPO3 page repository. Used for language and workspace overlay
54 *
55 * @var \TYPO3\CMS\Frontend\Page\PageRepository
56 */
57 protected $pageRepository;
58
59 /**
60 * A first-level TypoScript configuration cache
61 *
62 * @var array
63 */
64 protected $pageTSConfigCache = [];
65
66 /**
67 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
68 */
69 protected $configurationManager;
70
71 /**
72 * @var \TYPO3\CMS\Extbase\Service\CacheService
73 */
74 protected $cacheService;
75
76 /**
77 * @var \TYPO3\CMS\Extbase\Service\EnvironmentService
78 */
79 protected $environmentService;
80
81 /**
82 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
83 */
84 protected $objectManager;
85
86 /**
87 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper
88 */
89 public function injectDataMapper(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper $dataMapper)
90 {
91 $this->dataMapper = $dataMapper;
92 }
93
94 /**
95 * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
96 */
97 public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
98 {
99 $this->configurationManager = $configurationManager;
100 }
101
102 /**
103 * @param \TYPO3\CMS\Extbase\Service\CacheService $cacheService
104 */
105 public function injectCacheService(\TYPO3\CMS\Extbase\Service\CacheService $cacheService)
106 {
107 $this->cacheService = $cacheService;
108 }
109
110 /**
111 * @param \TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService
112 */
113 public function injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
114 {
115 $this->environmentService = $environmentService;
116 }
117
118 /**
119 * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
120 */
121 public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
122 {
123 $this->objectManager = $objectManager;
124 }
125
126 /**
127 * Constructor. takes the database handle from $GLOBALS['TYPO3_DB']
128 */
129 public function __construct()
130 {
131 $this->databaseHandle = $GLOBALS['TYPO3_DB'];
132 $this->connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
133 }
134
135 /**
136 * Adds a row to the storage
137 *
138 * @param string $tableName The database table name
139 * @param array $fieldValues The row to be inserted
140 * @param bool $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
141 * @return int The uid of the inserted row
142 * @throws SqlErrorException
143 */
144 public function addRow($tableName, array $fieldValues, $isRelation = false)
145 {
146 if (isset($fieldValues['uid'])) {
147 unset($fieldValues['uid']);
148 }
149 try {
150 $connection = $this->connectionPool->getConnectionForTable($tableName);
151 $connection->insert($tableName, $fieldValues);
152 } catch (DBALException $e) {
153 throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230766);
154 }
155
156 $uid = $connection->lastInsertId($tableName);
157
158 if (!$isRelation) {
159 $this->clearPageCache($tableName, $uid);
160 }
161 return (int)$uid;
162 }
163
164 /**
165 * Updates a row in the storage
166 *
167 * @param string $tableName The database table name
168 * @param array $fieldValues The row to be updated
169 * @param bool $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
170 * @throws \InvalidArgumentException
171 * @throws SqlErrorException
172 * @return bool
173 */
174 public function updateRow($tableName, array $fieldValues, $isRelation = false)
175 {
176 if (!isset($fieldValues['uid'])) {
177 throw new \InvalidArgumentException('The given row must contain a value for "uid".');
178 }
179
180 $uid = (int)$fieldValues['uid'];
181 unset($fieldValues['uid']);
182
183 try {
184 $this->connectionPool->getConnectionForTable($tableName)
185 ->update($tableName, $fieldValues, ['uid' => $uid]);
186 } catch (DBALException $e) {
187 throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230767);
188 }
189
190 if (!$isRelation) {
191 $this->clearPageCache($tableName, $uid);
192 }
193
194 // always returns true
195 return true;
196 }
197
198 /**
199 * Updates a relation row in the storage.
200 *
201 * @param string $tableName The database relation table name
202 * @param array $fieldValues The row to be updated
203 * @throws \InvalidArgumentException
204 * @return bool
205 * @throws SqlErrorException
206 */
207 public function updateRelationTableRow($tableName, array $fieldValues)
208 {
209 if (!isset($fieldValues['uid_local']) && !isset($fieldValues['uid_foreign'])) {
210 throw new \InvalidArgumentException(
211 'The given fieldValues must contain a value for "uid_local" and "uid_foreign".', 1360500126
212 );
213 }
214
215 $where['uid_local'] = (int)$fieldValues['uid_local'];
216 $where['uid_foreign'] = (int)$fieldValues['uid_foreign'];
217 unset($fieldValues['uid_local']);
218 unset($fieldValues['uid_foreign']);
219
220 if (!empty($fieldValues['tablenames'])) {
221 $where['tablenames'] = $fieldValues['tablenames'];
222 unset($fieldValues['tablenames']);
223 }
224 if (!empty($fieldValues['fieldname'])) {
225 $where['fieldname'] = $fieldValues['fieldname'];
226 unset($fieldValues['fieldname']);
227 }
228
229 try {
230 $this->connectionPool->getConnectionForTable($tableName)
231 ->update($tableName, $fieldValues, $where);
232 } catch (DBALException $e) {
233 throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230768);
234 }
235
236 // always returns true
237 return true;
238 }
239
240 /**
241 * Deletes a row in the storage
242 *
243 * @param string $tableName The database table name
244 * @param array $where An array of where array('fieldname' => value).
245 * @param bool $isRelation TRUE if we are currently manipulating a relation table, FALSE by default
246 * @return bool
247 * @throws SqlErrorException
248 */
249 public function removeRow($tableName, array $where, $isRelation = false)
250 {
251 try {
252 $this->connectionPool->getConnectionForTable($tableName)->delete($tableName, $where);
253 } catch (DBALException $e) {
254 throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230769);
255 }
256
257 if (!$isRelation && isset($where['uid'])) {
258 $this->clearPageCache($tableName, $where['uid']);
259 }
260
261 // always returns true
262 return true;
263 }
264
265 /**
266 * Fetches maximal value for given table column from database.
267 *
268 * @param string $tableName The database table name
269 * @param array $where An array of where array('fieldname' => value).
270 * @param string $columnName column name to get the max value from
271 * @return mixed the max value
272 * @throws SqlErrorException
273 */
274 public function getMaxValueFromTable($tableName, array $where, $columnName)
275 {
276 try {
277 $queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
278 $queryBuilder->getRestrictions()->removeAll();
279 $queryBuilder
280 ->select($columnName)
281 ->from($tableName)
282 ->orderBy($columnName, 'DESC')
283 ->setMaxResults(1);
284
285 foreach ($where as $fieldName => $value) {
286 $queryBuilder->andWhere(
287 $queryBuilder->expr()->eq($fieldName, $queryBuilder->createNamedParameter($value))
288 );
289 }
290
291 $result = $queryBuilder->execute()->fetchColumn(0);
292 } catch (DBALException $e) {
293 throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230770);
294 }
295 return $result;
296 }
297
298 /**
299 * Fetches row data from the database
300 *
301 * @param string $tableName
302 * @param array $where An array of where array('fieldname' => value).
303 * @return array|bool
304 * @throws SqlErrorException
305 */
306 public function getRowByIdentifier($tableName, array $where)
307 {
308 try {
309 $queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
310 $queryBuilder->getRestrictions()->removeAll();
311 $queryBuilder
312 ->select('*')
313 ->from($tableName);
314
315 foreach ($where as $fieldName => $value) {
316 $queryBuilder->andWhere(
317 $queryBuilder->expr()->eq($fieldName, $queryBuilder->createNamedParameter($value))
318 );
319 }
320
321 $row = $queryBuilder->execute()->fetch();
322 } catch (DBALException $e) {
323 throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230771);
324 }
325 return $row ?: false;
326 }
327
328 /**
329 * Returns the object data matching the $query.
330 *
331 * @param QueryInterface $query
332 * @return array
333 * @throws SqlErrorException
334 */
335 public function getObjectDataByQuery(QueryInterface $query)
336 {
337 $statement = $query->getStatement();
338 if ($statement instanceof Qom\Statement) {
339 $rows = $this->getObjectDataByRawQuery($statement);
340 } else {
341 $queryBuilder = $this->objectManager->get(Typo3DbQueryParser::class)
342 ->convertQueryToDoctrineQueryBuilder($query);
343 if ($query->getOffset()) {
344 $queryBuilder->setFirstResult($query->getOffset());
345 }
346 if ($query->getLimit()) {
347 $queryBuilder->setMaxResults($query->getLimit());
348 }
349 try {
350 $rows = $queryBuilder->execute()->fetchAll();
351 } catch (DBALException $e) {
352 throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074485);
353 }
354 }
355
356 $rows = $this->doLanguageAndWorkspaceOverlay($query->getSource(), $rows, $query->getQuerySettings());
357 return $rows;
358 }
359
360 /**
361 * Returns the object data using a custom statement
362 *
363 * @param Qom\Statement $statement
364 * @return array
365 * @throws SqlErrorException when the raw SQL statement fails in the database
366 */
367 protected function getObjectDataByRawQuery(Qom\Statement $statement)
368 {
369 $realStatement = $statement->getStatement();
370 $parameters = $statement->getBoundVariables();
371
372 if ($realStatement instanceof \TYPO3\CMS\Core\Database\PreparedStatement) {
373 $realStatement->execute($parameters);
374 $rows = $realStatement->fetchAll();
375
376 $realStatement->free();
377 } else {
378 // Do a real raw query. This is very stupid, as it does not allow to use DBAL's real power if
379 // several tables are on different databases, so this is used with caution and could be removed
380 // in the future
381 try {
382 $connection = $this->connectionPool->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
383 $statement = $connection->executeQuery($realStatement);
384 } catch (DBALException $e) {
385 throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064775);
386 }
387
388 $rows = [];
389 while ($row = $statement->fetch()) {
390 if (is_array($row)) {
391 $rows[] = $row;
392 }
393 }
394 }
395
396 return $rows;
397 }
398
399 /**
400 * Returns the number of tuples matching the query.
401 *
402 * @param QueryInterface $query
403 * @throws Exception\BadConstraintException
404 * @return int The number of matching tuples
405 * @throws SqlErrorException
406 */
407 public function getObjectCountByQuery(QueryInterface $query)
408 {
409 if ($query->getConstraint() instanceof Qom\Statement) {
410 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\BadConstraintException('Could not execute count on queries with a constraint of type TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Statement', 1256661045);
411 }
412
413 $queryBuilder = $this->objectManager->get(Typo3DbQueryParser::class)
414 ->convertQueryToDoctrineQueryBuilder($query);
415 try {
416 $count = $queryBuilder->count('*')->execute()->fetchColumn(0);
417 } catch (DBALException $e) {
418 throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074379);
419 }
420 if ($query->getOffset()) {
421 $count -= $query->getOffset();
422 }
423 if ($query->getLimit()) {
424 $count = min($count, $query->getLimit());
425 }
426 return (int)max(0, $count);
427 }
428
429 /**
430 * Checks if a Value Object equal to the given Object exists in the database
431 *
432 * @param AbstractValueObject $object The Value Object
433 * @return mixed The matching uid if an object was found, else FALSE
434 * @throws SqlErrorException
435 */
436 public function getUidOfAlreadyPersistedValueObject(AbstractValueObject $object)
437 {
438 $dataMap = $this->dataMapper->getDataMap(get_class($object));
439 $tableName = $dataMap->getTableName();
440 $queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
441 if ($this->environmentService->isEnvironmentInFrontendMode()) {
442 $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
443 }
444 $whereClause = [];
445 // loop over all properties of the object to exactly set the values of each database field
446 $properties = $object->_getProperties();
447 foreach ($properties as $propertyName => $propertyValue) {
448 // @todo We couple the Backend to the Entity implementation (uid, isClone); changes there breaks this method
449 if ($dataMap->isPersistableProperty($propertyName) && $propertyName !== 'uid' && $propertyName !== 'pid' && $propertyName !== 'isClone') {
450 $fieldName = $dataMap->getColumnMap($propertyName)->getColumnName();
451 if ($propertyValue === null) {
452 $whereClause[] = $queryBuilder->expr()->isNull($fieldName);
453 } else {
454 $whereClause[] = $queryBuilder->expr()->eq($fieldName, $queryBuilder->createNamedParameter($this->dataMapper->getPlainValue($propertyValue)));
455 }
456 }
457 }
458 $queryBuilder
459 ->select('uid')
460 ->from($tableName)
461 ->where(...$whereClause);
462
463 try {
464 $uid = (int)$queryBuilder
465 ->execute()
466 ->fetchColumn(0);
467 if ($uid > 0) {
468 return $uid;
469 } else {
470 return false;
471 }
472 } catch (DBALException $e) {
473 throw new SqlErrorException($e->getPrevious()->getMessage(), 1470231748);
474 }
475 }
476
477 /**
478 * Performs workspace and language overlay on the given row array. The language and workspace id is automatically
479 * detected (depending on FE or BE context). You can also explicitly set the language/workspace id.
480 *
481 * @param Qom\SourceInterface $source The source (selector od join)
482 * @param array $rows
483 * @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The TYPO3 CMS specific query settings
484 * @param null|int $workspaceUid
485 * @return array
486 */
487 protected function doLanguageAndWorkspaceOverlay(Qom\SourceInterface $source, array $rows, \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings, $workspaceUid = null)
488 {
489 if ($source instanceof Qom\SelectorInterface) {
490 $tableName = $source->getSelectorName();
491 } elseif ($source instanceof Qom\JoinInterface) {
492 $tableName = $source->getRight()->getSelectorName();
493 } else {
494 // No proper source, so we do not have a table name here
495 // we cannot do an overlay and return the original rows instead.
496 return $rows;
497 }
498
499 $pageRepository = $this->getPageRepository();
500 if (is_object($GLOBALS['TSFE'])) {
501 if ($workspaceUid !== null) {
502 $pageRepository->versioningWorkspaceId = $workspaceUid;
503 }
504 } else {
505 if ($workspaceUid === null) {
506 $workspaceUid = $GLOBALS['BE_USER']->workspace;
507 }
508 $pageRepository->versioningWorkspaceId = $workspaceUid;
509 }
510
511 // Fetches the move-placeholder in case it is supported
512 // by the table and if there's only one row in the result set
513 // (applying this to all rows does not work, since the sorting
514 // order would be destroyed and possible limits not met anymore)
515 if (!empty($pageRepository->versioningWorkspaceId)
516 && BackendUtility::isTableWorkspaceEnabled($tableName)
517 && count($rows) === 1
518 ) {
519 $movePlaceholder = $this->databaseHandle->exec_SELECTgetSingleRow(
520 $tableName . '.*',
521 $tableName,
522 't3ver_state=3 AND t3ver_wsid=' . $pageRepository->versioningWorkspaceId
523 . ' AND t3ver_move_id=' . $rows[0]['uid']
524 );
525 if (!empty($movePlaceholder)) {
526 $rows = [$movePlaceholder];
527 }
528 }
529
530 $overlaidRows = [];
531 foreach ($rows as $row) {
532 // If current row is a translation select its parent
533 if (isset($tableName) && isset($GLOBALS['TCA'][$tableName])
534 && isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
535 && isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
536 && !isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerTable'])
537 ) {
538 if (isset($row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']])
539 && $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0
540 ) {
541 $row = $this->databaseHandle->exec_SELECTgetSingleRow(
542 $tableName . '.*',
543 $tableName,
544 $tableName . '.uid=' . (int)$row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] .
545 ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . '=0'
546 );
547 }
548 }
549 $pageRepository->versionOL($tableName, $row, true);
550 if ($tableName == 'pages') {
551 $row = $pageRepository->getPageOverlay($row, $querySettings->getLanguageUid());
552 } elseif (isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
553 && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== ''
554 && !isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerTable'])
555 ) {
556 if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']], [-1, 0])) {
557 $overlayMode = $querySettings->getLanguageMode() === 'strict' ? 'hideNonTranslated' : '';
558 $row = $pageRepository->getRecordOverlay($tableName, $row, $querySettings->getLanguageUid(), $overlayMode);
559 }
560 }
561 if ($row !== null && is_array($row)) {
562 $overlaidRows[] = $row;
563 }
564 }
565 return $overlaidRows;
566 }
567
568 /**
569 * @return \TYPO3\CMS\Frontend\Page\PageRepository
570 */
571 protected function getPageRepository()
572 {
573 if (!$this->pageRepository instanceof \TYPO3\CMS\Frontend\Page\PageRepository) {
574 if ($this->environmentService->isEnvironmentInFrontendMode() && is_object($GLOBALS['TSFE'])) {
575 $this->pageRepository = $GLOBALS['TSFE']->sys_page;
576 } else {
577 $this->pageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
578 }
579 }
580
581 return $this->pageRepository;
582 }
583
584 /**
585 * Clear the TYPO3 page cache for the given record.
586 * If the record lies on a page, then we clear the cache of this page.
587 * If the record has no PID column, we clear the cache of the current page as best-effort.
588 *
589 * Much of this functionality is taken from DataHandler::clear_cache() which unfortunately only works with logged-in BE user.
590 *
591 * @param string $tableName Table name of the record
592 * @param int $uid UID of the record
593 * @return void
594 */
595 protected function clearPageCache($tableName, $uid)
596 {
597 $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
598 if (isset($frameworkConfiguration['persistence']['enableAutomaticCacheClearing']) && $frameworkConfiguration['persistence']['enableAutomaticCacheClearing'] === '1') {
599 } else {
600 // if disabled, return
601 return;
602 }
603 $pageIdsToClear = [];
604 $storagePage = null;
605 $columns = GeneralUtility::makeInstance(ConnectionPool::class)
606 ->getConnectionForTable($tableName)
607 ->getSchemaManager()
608 ->listTableColumns($tableName);
609 if (array_key_exists('pid', $columns)) {
610 $queryBuilder = $this->connectionPool->getQueryBuilderForTable($tableName);
611 $queryBuilder->getRestrictions()->removeAll();
612 $result = $queryBuilder
613 ->select('pid')
614 ->from($tableName)
615 ->where($queryBuilder->expr()->eq('uid', (int)$uid))
616 ->execute();
617 if ($row = $result->fetch()) {
618 $storagePage = $row['pid'];
619 $pageIdsToClear[] = $storagePage;
620 }
621 } elseif (isset($GLOBALS['TSFE'])) {
622 // No PID column - we can do a best-effort to clear the cache of the current page if in FE
623 $storagePage = $GLOBALS['TSFE']->id;
624 $pageIdsToClear[] = $storagePage;
625 }
626 if ($storagePage === null) {
627 return;
628 }
629 if (!isset($this->pageTSConfigCache[$storagePage])) {
630 $this->pageTSConfigCache[$storagePage] = BackendUtility::getPagesTSconfig($storagePage);
631 }
632 if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) {
633 $clearCacheCommands = GeneralUtility::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), true);
634 $clearCacheCommands = array_unique($clearCacheCommands);
635 foreach ($clearCacheCommands as $clearCacheCommand) {
636 if (MathUtility::canBeInterpretedAsInteger($clearCacheCommand)) {
637 $pageIdsToClear[] = $clearCacheCommand;
638 }
639 }
640 }
641
642 foreach ($pageIdsToClear as $pageIdToClear) {
643 $this->cacheService->getPageIdStack()->push($pageIdToClear);
644 }
645 }
646 }