Extbase:
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Storage / Typo3DbBackend.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * A Storage backend
30 *
31 * @package Extbase
32 * @subpackage Persistence
33 * @version $Id: $
34 */
35 class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persistence_Storage_BackendInterface, t3lib_Singleton {
36
37 const OPERATOR_EQUAL_TO_NULL = 'operatorEqualToNull';
38 const OPERATOR_NOT_EQUAL_TO_NULL = 'operatorNotEqualToNull';
39
40 /**
41 * The TYPO3 database object
42 *
43 * @var t3lib_db
44 */
45 protected $databaseHandle;
46
47 /**
48 * The TYPO3 page select object. Used for language and workspace overlay
49 *
50 * @var t3lib_pageSelect
51 */
52 protected $pageSelectObject;
53
54 /**
55 * TRUE if the framework should add the "enable fields" (e.g. checking for hidden or deleted records)
56 *
57 * @var boolean
58 */
59 protected $useEnableFields = TRUE;
60
61 /**
62 * TRUE if automatic cache clearing in TCEMAIN should be done on insert/update/delete, FALSE otherwise.
63 *
64 * @var boolean
65 */
66 protected $automaticCacheClearing = FALSE;
67
68 /**
69 * Constructs this Storage Backend instance
70 *
71 * @param t3lib_db $databaseHandle The database handle
72 */
73 public function __construct($databaseHandle) {
74 $this->databaseHandle = $databaseHandle;
75 }
76
77 /**
78 * Set the automatic cache clearing flag.
79 * If TRUE, then inserted/updated/deleted records trigger a TCEMAIN cache clearing.
80 *
81 * @param $automaticCacheClearing boolean if TRUE, enables automatic cache clearing
82 * @return void
83 * @internal
84 */
85 public function setAutomaticCacheClearing($automaticCacheClearing) {
86 $this->automaticCacheClearing = (boolean)$automaticCacheClearing;
87 }
88
89 /**
90 * Adds a row to the storage
91 *
92 * @param string $tableName The database table name
93 * @param array $row The row to be inserted
94 * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
95 * @return int The uid of the inserted row
96 */
97 public function addRow($tableName, array $row, $isRelation = FALSE) {
98 $fields = array();
99 $values = array();
100 $parameters = array();
101 unset($row['uid']); // TODO Check if the offset exists
102 foreach ($row as $columnName => $value) {
103 $fields[] = $columnName;
104 $values[] = '?';
105 $parameters[] = $value;
106 }
107
108 $sqlString = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
109 $this->replacePlaceholders($sqlString, $parameters);
110
111 $this->databaseHandle->sql_query($sqlString);
112 $uid = $this->databaseHandle->sql_insert_id();
113 if (!$isRelation) {
114 $this->clearPageCache($tableName, $uid);
115 }
116 return $uid;
117 }
118
119 /**
120 * Updates a row in the storage
121 *
122 * @param string $tableName The database table name
123 * @param array $row The row to be updated
124 * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
125 * @return void
126 */
127 public function updateRow($tableName, array $row, $isRelation = FALSE) {
128 if (!isset($row['uid'])) throw new InvalidArgumentException('The given row must contain a value for "uid".');
129 $uid = (int)$row['uid'];
130 unset($row['uid']);
131 $fields = array();
132 $parameters = array();
133 foreach ($row as $columnName => $value) {
134 $fields[] = $columnName . '=?';
135 $parameters[] = $value;
136 }
137 $parameters[] = $uid;
138
139 $sqlString = 'UPDATE ' . $tableName . ' SET ' . implode(', ', $fields) . ' WHERE uid=?';
140 $this->replacePlaceholders($sqlString, $parameters);
141
142 $returnValue = $this->databaseHandle->sql_query($sqlString);
143 if (!$isRelation) {
144 $this->clearPageCache($tableName, $uid);
145 }
146 return $returnValue;
147 }
148
149 /**
150 * Deletes a row in the storage
151 *
152 * @param string $tableName The database table name
153 * @param array $uid The uid of the row to be deleted
154 * @param boolean $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
155 * @return void
156 */
157 public function removeRow($tableName, $uid, $isRelation = FALSE) {
158 $sqlString = 'DELETE FROM ' . $tableName . ' WHERE uid=?';
159 $this->replacePlaceholders($sqlString, array((int)$uid));
160 if (!$isRelation) {
161 $this->clearPageCache($tableName, $uid, $isRelation);
162 }
163 $returnValue = $this->databaseHandle->sql_query($sqlString);
164 return $returnValue;
165 }
166
167 /**
168 * Returns an array with tuples matching the query.
169 *
170 * @param Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query
171 * @return array The matching tuples
172 */
173 public function getRows(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query) {
174 $sql = array();
175 $sql['tables'] = array();
176 $sql['fields'] = array();
177 $sql['where'] = array();
178 $sql['enableFields'] = array();
179 $sql['orderings'] = array();
180 $parameters = array();
181 $tuples = array();
182
183 $this->parseSource($query, $sql, $parameters);
184 $sqlString = 'SELECT ' . implode(',', $sql['fields']) . ' FROM ' . implode(' ', $sql['tables']);
185
186 $this->parseConstraint($query->getConstraint(), $sql, $parameters, $query->getBoundVariableValues());
187 if (!empty($sql['where'])) {
188 $sqlString .= ' WHERE ' . implode('', $sql['where']);
189 if (!empty($sql['enableFields'])) {
190 $sqlString .= ' AND ' . implode(' AND ', $sql['enableFields']);
191 }
192 } elseif (!empty($sql['enableFields'])) {
193 $sqlString .= ' WHERE ' . implode(' AND ', $sql['enableFields']);
194 }
195
196 $this->parseOrderings($query->getOrderings(), $sql, $parameters, $query->getBoundVariableValues());
197 if (!empty($sql['orderings'])) {
198 $sqlString .= ' ORDER BY ' . implode(', ', $sql['orderings']);
199 }
200
201 $this->replacePlaceholders($sqlString, $parameters);
202
203 $result = $this->databaseHandle->sql_query($sqlString);
204 if ($result) {
205 // TODO Check for selector name
206 $tuples = $this->getRowsFromResult($query->getSelectorName(), $result);
207 }
208
209 return $tuples;
210 }
211
212 /**
213 * Checks if a Value Object equal to the given Object exists in the data base
214 *
215 * @param array $properties The properties of the Value Object
216 * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap The Data Map
217 * @return array The matching tuples
218 */
219 public function hasValueObject(array $properties, Tx_Extbase_Persistence_Mapper_DataMap $dataMap) {
220 $fields = array();
221 $parameters = array();
222 foreach ($properties as $propertyName => $propertyValue) {
223 if ($dataMap->isPersistableProperty($propertyName) && ($propertyName !== 'uid')) {
224 $fields[] = $dataMap->getColumnMap($propertyName)->getColumnName() . '=?';
225 $parameters[] = $dataMap->convertPropertyValueToFieldValue($propertyValue);
226 }
227 }
228
229 $sqlString = 'SELECT * FROM ' . $dataMap->getTableName() . ' WHERE ' . implode('', $fields);
230 $this->replacePlaceholders($sqlString, $parameters);
231 $res = $this->databaseHandle->sql_query($sqlString);
232 $row = $this->databaseHandle->sql_fetch_assoc($res);
233 if ($row !== FALSE) {
234 return $row['uid'];
235 } else {
236 return FALSE;
237 }
238 }
239
240 /**
241 * Transforms a Query Source into SQL and parameter arrays
242 *
243 * @param Tx_Extbase_Persistence_QOM_QueryObjectModel $query
244 * @param array &$sql
245 * @param array &$parameters
246 * @return void
247 */
248 protected function parseSource(Tx_Extbase_Persistence_QOM_QueryObjectModel $query, array &$sql, array &$parameters) {
249 $source = $query->getSource();
250 if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
251 $selectorName = $source->getSelectorName();
252 $sql['fields'][] = $selectorName . '.*';
253 $sql['tables'][] = $selectorName;
254 // TODO Should we make the usage of enableFields configurable? And how? Because the Query object and even the QOM should be abstracted from the storage backend.
255 if ($this->useEnableFields === TRUE) {
256 $this->addEnableFieldsStatement($selectorName, $sql);
257 }
258 } elseif ($source instanceof Tx_Extbase_Persistence_QOM_JoinInterface) {
259 $this->parseJoin($source, $sql, $parameters);
260 }
261 }
262
263 /**
264 * Transforms a Join into SQL and parameter arrays
265 *
266 * @param Tx_Extbase_Persistence_QOM_JoinInterface $join
267 * @param array &$sql
268 * @param array &$parameters
269 * @return void
270 */
271 protected function parseJoin(Tx_Extbase_Persistence_QOM_JoinInterface $join, array &$sql, array &$parameters) {
272 $leftSelectorName = $join->getLeft()->getSelectorName();
273 $rightSelectorName = $join->getRight()->getSelectorName();
274
275 $sql['fields'][] = $leftSelectorName . '.*';
276 $sql['fields'][] = $rightSelectorName . '.*';
277
278 // TODO Implement support for different join types and nested joins
279 $sql['tables'][] = $leftSelectorName . ' LEFT JOIN ' . $rightSelectorName;
280
281 $joinCondition = $join->getJoinCondition();
282 // TODO Check the parsing of the join
283 if ($joinCondition instanceof Tx_Extbase_Persistence_QOM_EquiJoinCondition) {
284 $sql['tables'][] = 'ON ' . $joinCondition->getSelector1Name() . '.' . $joinCondition->getProperty1Name() . ' = ' . $joinCondition->getSelector2Name() . '.' . $joinCondition->getProperty2Name();
285 }
286 // TODO Implement childtableWhere
287
288 $this->addEnableFieldsStatement($leftSelectorName, $sql);
289 $this->addEnableFieldsStatement($rightSelectorName, $sql);
290 }
291
292 /**
293 * Transforms a constraint into SQL and parameter arrays
294 *
295 * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint
296 * @param array &$sql
297 * @param array &$parameters
298 * @param array $boundVariableValues
299 * @return void
300 */
301 protected function parseConstraint(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint = NULL, array &$sql, array &$parameters, array $boundVariableValues) {
302 if ($constraint instanceof Tx_Extbase_Persistence_QOM_AndInterface) {
303 $sql['where'][] = '(';
304 $this->parseConstraint($constraint->getConstraint1(), $sql, $parameters, $boundVariableValues);
305 $sql['where'][] = ' AND ';
306 $this->parseConstraint($constraint->getConstraint2(), $sql, $parameters, $boundVariableValues);
307 $sql['where'][] = ')';
308 } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_OrInterface) {
309 $sql['where'][] = '(';
310 $this->parseConstraint($constraint->getConstraint1(), $sql, $parameters, $boundVariableValues);
311 $sql['where'][] = ' OR ';
312 $this->parseConstraint($constraint->getConstraint2(), $sql, $parameters, $boundVariableValues);
313 $sql['where'][] = ')';
314 } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_NotInterface) {
315 $sql['where'][] = 'NOT (';
316 $this->parseConstraint($constraint->getConstraint(), $sql, $parameters, $boundVariableValues);
317 $sql['where'][] = ')';
318 } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_ComparisonInterface) {
319 $this->parseComparison($constraint, $sql, $parameters, $boundVariableValues);
320 } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_RelatedInterface) {
321 $this->parseRelated($constraint, $sql, $parameters, $boundVariableValues);
322 }
323 }
324
325 /**
326 * Parse a Comparison into SQL and parameter arrays.
327 *
328 * @param Tx_Extbase_Persistence_QOM_ComparisonInterface $comparison The comparison to parse
329 * @param array &$sql SQL query parts to add to
330 * @param array &$parameters Parameters to bind to the SQL
331 * @param array $boundVariableValues The bound variables in the query and their values
332 * @return void
333 */
334 protected function parseComparison(Tx_Extbase_Persistence_QOM_ComparisonInterface $comparison, array &$sql, array &$parameters, array $boundVariableValues) {
335 if (!($comparison->getOperand2() instanceof Tx_Extbase_Persistence_QOM_BindVariableValueInterface)) throw new Tx_Extbase_Persistence_Exception('Type of operand is not supported', 1247581135);
336
337 $value = $boundVariableValues[$comparison->getOperand2()->getBindVariableName()];
338 $operator = $comparison->getOperator();
339 if ($value === NULL) {
340 if ($operator === Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO) {
341 $operator = self::OPERATOR_EQUAL_TO_NULL;
342 } elseif ($operator === Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_NOT_EQUAL_TO) {
343 $operator = self::OPERATOR_NOT_EQUAL_TO_NULL;
344 } else {
345 // TODO Throw exception
346 }
347 }
348 $parameters[] = $value;
349
350 $this->parseDynamicOperand($comparison->getOperand1(), $operator, $sql, $parameters);
351 }
352
353 /**
354 * Parse a DynamicOperand into SQL and parameter arrays.
355 *
356 * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand
357 * @param string $operator One of the JCR_OPERATOR_* constants
358 * @param array $boundVariableValues
359 * @param array &$parameters
360 * @param string $valueFunction an aoptional SQL function to apply to the operand value
361 * @return void
362 */
363 protected function parseDynamicOperand(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand, $operator, array &$sql, array &$parameters, $valueFunction = NULL) {
364 if ($operand instanceof Tx_Extbase_Persistence_QOM_LowerCaseInterface) {
365 $this->parseDynamicOperand($operand->getOperand(), $operator, $sql, $parameters, 'LOWER');
366 } elseif ($operand instanceof Tx_Extbase_Persistence_QOM_UpperCaseInterface) {
367 $this->parseDynamicOperand($operand->getOperand(), $operator, $sql, $parameters, 'UPPER');
368 } elseif ($operand instanceof Tx_Extbase_Persistence_QOM_PropertyValueInterface) {
369 $selectorName = $operand->getSelectorName();
370 $operator = $this->resolveOperator($operator);
371
372 if ($valueFunction === NULL) {
373 $constraintSQL .= (!empty($selectorName) ? $selectorName . '.' : '') . $operand->getPropertyName() . ' ' . $operator . ' ?';
374 } else {
375 $constraintSQL .= $valueFunction . '(' . (!empty($selectorName) ? $selectorName . '.' : '') . $operand->getPropertyName() . ' ' . $operator . ' ?';
376 }
377
378 $sql['where'][] = $constraintSQL;
379 }
380 }
381
382 /**
383 * Returns the SQL operator for the given JCR operator type.
384 *
385 * @param string $operator One of the JCR_OPERATOR_* constants
386 * @return string an SQL operator
387 */
388 protected function resolveOperator($operator) {
389 switch ($operator) {
390 case self::OPERATOR_EQUAL_TO_NULL:
391 $operator = 'IS';
392 break;
393 case self::OPERATOR_NOT_EQUAL_TO_NULL:
394 $operator = 'IS NOT';
395 break;
396 case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO:
397 $operator = '=';
398 break;
399 case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_NOT_EQUAL_TO:
400 $operator = '!=';
401 break;
402 case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN:
403 $operator = '<';
404 break;
405 case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO:
406 $operator = '<=';
407 break;
408 case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN:
409 $operator = '>';
410 break;
411 case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO:
412 $operator = '>=';
413 break;
414 case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LIKE:
415 $operator = 'LIKE';
416 break;
417 default:
418 throw new Tx_Extbase_Persistence_Exception('Unsupported operator encountered.', 1242816073);
419 }
420
421 return $operator;
422 }
423
424 /**
425 * Replace query placeholders in a query part by the given
426 * parameters.
427 *
428 * @param string $queryPart The query part with placeholders
429 * @param array $parameters The parameters
430 * @return string The query part with replaced placeholders
431 */
432 protected function replacePlaceholders(&$sqlString, array $parameters) {
433 if (substr_count($sqlString, '?') !== count($parameters)) throw new Tx_Extbase_Persistence_Exception('The number of question marks to replace must be equal to the number of parameters.', 1242816074);
434 foreach ($parameters as $parameter) {
435 $markPosition = strpos($sqlString, '?');
436 if ($markPosition !== FALSE) {
437 // TODO This is a bit hacky; improve the handling of $parameter === NULL
438 if ($parameter === NULL) {
439 $parameter = 'NULL';
440 } else {
441 $parameter = '"' . $parameter . '"';
442 }
443 $sqlString = substr($sqlString, 0, $markPosition) . $parameter . substr($sqlString, $markPosition + 1);
444 }
445 }
446 }
447
448 /**
449 * Builds the enable fields statement
450 *
451 * @param string $selectorName The selector name (= database table name)
452 * @param array &$sql The query parts
453 * @return void
454 */
455 protected function addEnableFieldsStatement($selectorName, array &$sql) {
456 // TODO We have to call the appropriate API method if we are in TYPO3BE mode
457 if (is_array($GLOBALS['TCA'][$selectorName]['ctrl'])) {
458 $statement = substr($GLOBALS['TSFE']->sys_page->enableFields($selectorName), 4);
459 if(!empty($statement)) {
460 $sql['enableFields'][] = $statement;
461 }
462 }
463 }
464
465 /**
466 * Transforms orderings into SQL
467 *
468 * @param array $orderings
469 * @param array &$sql
470 * @param array &$parameters
471 * @param array $boundVariableValues
472 * @return void
473 */
474 protected function parseOrderings(array $orderings = NULL, array &$sql, array &$parameters, array $boundVariableValues) {
475 if (is_array($orderings)) {
476 foreach ($orderings as $propertyName => $ordering) {
477 // TODO Implement
478 }
479 }
480 }
481
482 /**
483 * Transforms a Resource from a database query to an array of rows. Performs the language and
484 * workspace overlay before.
485 *
486 * @return array The result as an array of rows (tuples)
487 */
488 protected function getRowsFromResult($tableName, $res) {
489 $rows = array();
490 while ($row = $this->databaseHandle->sql_fetch_assoc($res)) {
491 $row = $this->doLanguageAndWorkspaceOverlay($tableName, $row);
492 if (is_array($row)) {
493 // TODO Check if this is necessary, maybe the last line is enough
494 $arrayKeys = range(0,count($row));
495 array_fill_keys($arrayKeys, $row);
496 $rows[] = $row;
497 }
498 }
499 return $rows;
500 }
501
502 /**
503 * Performs workspace and language overlay on the given row array. The language and workspace id is automatically
504 * detected (depending on FE or BE context). You can also explicitly set the language/workspace id.
505 *
506 * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap
507 * @param array $row The row array (as reference)
508 * @param string $languageUid The language id
509 * @param string $workspaceUidUid The workspace id
510 * @return void
511 */
512 protected function doLanguageAndWorkspaceOverlay($tableName, array $row, $languageUid = NULL, $workspaceUid = NULL) {
513 if (!($this->pageSelectObject instanceof t3lib_pageSelect)) {
514 if (TYPO3_MODE == 'FE') {
515 if (is_object($GLOBALS['TSFE'])) {
516 $this->pageSelectObject = $GLOBALS['TSFE']->sys_page;
517 if ($languageUid === NULL) {
518 $languageUid = $GLOBALS['TSFE']->sys_language_content;
519 }
520 } else {
521 require_once(PATH_t3lib . 'class.t3lib_page.php');
522 $this->pageSelectObject = t3lib_div::makeInstance('t3lib_pageSelect');
523 if ($languageUid === NULL) {
524 $languageUid = intval(t3lib_div::_GP('L'));
525 }
526 }
527 if ($workspaceUid !== NULL) {
528 $this->pageSelectObject->versioningWorkspaceId = $workspaceUid;
529 }
530 } else {
531 require_once(PATH_t3lib . 'class.t3lib_page.php');
532 $this->pageSelectObject = t3lib_div::makeInstance( 't3lib_pageSelect' );
533 //$this->pageSelectObject->versioningPreview = TRUE;
534 if ($workspaceUid === NULL) {
535 $workspaceUid = $GLOBALS['BE_USER']->workspace;
536 }
537 $this->pageSelectObject->versioningWorkspaceId = $workspaceUid;
538 }
539 }
540
541 $this->pageSelectObject->versionOL($tableName, $row, TRUE);
542 $row = $this->pageSelectObject->getRecordOverlay($tableName, $row, $languageUid, ''); //'hideNonTranslated'
543 // TODO Skip if empty languageoverlay (languagevisibility)
544 return $row;
545 }
546
547 /**
548 * Clear the TYPO3 page cache for the given record.
549 * Much of this functionality is taken from t3lib_tcemain::clear_cache() which unfortunately only works with logged-in BE user.
550 *
551 * @param $tableName Table name of the record
552 * @param $uid UID of the record
553 * @return void
554 */
555 protected function clearPageCache($tableName, $uid) {
556 if ($this->automaticCacheClearing !== TRUE) return;
557
558 $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
559 $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
560
561 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid', $tableName, 'uid='.intval($uid));
562
563 $pageIdsToClear = array();
564 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
565 $storagePage = $row['pid'];
566 $pageIdsToClear[] = $storagePage;
567 }
568 if (!$storagePage) {
569 return;
570 }
571
572 $pageTSConfig = t3lib_BEfunc::getPagesTSconfig($storagePage);
573
574 if ($pageTSConfig['clearCacheCmd']) {
575 $clearCacheCommands = t3lib_div::trimExplode(',',strtolower($TSConfig['clearCacheCmd']),1);
576 $clearCacheCommands = array_unique($clearCacheCommands);
577 foreach ($clearCacheCommands as $clearCacheCommand) {
578 if (t3lib_div::testInt($clearCacheCommand)) {
579 $pageIdsToClear[] = $clearCacheCommand;
580 }
581 }
582 }
583
584 foreach ($pageIdsToClear as $pageIdToClear) {
585 $pageCache->flushByTag('pageId_' . $pageIdToClear);
586 $pageSectionCache->flushByTag('pageId_' . $pageIdToClear);
587 }
588 }
589 }
590
591 ?>