TYPO3 CMS  TYPO3_7-6
Typo3DbBackend.php
Go to the documentation of this file.
1 <?php
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 
37 
42 {
48  protected $databaseHandle;
49 
53  protected $dataMapper;
54 
60  protected $pageRepository;
61 
67  protected $pageTSConfigCache = [];
68 
73 
77  protected $cacheService;
78 
82  protected $cacheManager;
83 
87  protected $queryCache;
88 
93 
97  protected $queryParser;
98 
104  protected $queryRuntimeCache = [];
105 
110  {
111  $this->dataMapper = $dataMapper;
112  }
113 
118  {
119  $this->configurationManager = $configurationManager;
120  }
121 
126  {
127  $this->cacheService = $cacheService;
128  }
129 
134  {
135  $this->cacheManager = $cacheManager;
136  }
137 
142  {
143  $this->environmentService = $environmentService;
144  }
145 
150  {
151  $this->queryParser = $queryParser;
152  }
153 
157  public function __construct()
158  {
159  $this->databaseHandle = $GLOBALS['TYPO3_DB'];
160  }
161 
167  public function initializeObject()
168  {
169  $this->queryCache = $this->cacheManager->getCache('extbase_typo3dbbackend_queries');
170  }
171 
180  public function addRow($tableName, array $fieldValues, $isRelation = false)
181  {
182  if (isset($fieldValues['uid'])) {
183  unset($fieldValues['uid']);
184  }
185 
186  $this->databaseHandle->exec_INSERTquery($tableName, $fieldValues);
187  $this->checkSqlErrors();
188  $uid = $this->databaseHandle->sql_insert_id();
189 
190  if (!$isRelation) {
191  $this->clearPageCache($tableName, $uid);
192  }
193  return (int)$uid;
194  }
195 
205  public function updateRow($tableName, array $fieldValues, $isRelation = false)
206  {
207  if (!isset($fieldValues['uid'])) {
208  throw new \InvalidArgumentException('The given row must contain a value for "uid".');
209  }
210 
211  $uid = (int)$fieldValues['uid'];
212  unset($fieldValues['uid']);
213 
214  $updateSuccessful = $this->databaseHandle->exec_UPDATEquery($tableName, 'uid = ' . $uid, $fieldValues);
215  $this->checkSqlErrors();
216 
217  if (!$isRelation) {
218  $this->clearPageCache($tableName, $uid);
219  }
220 
221  return $updateSuccessful;
222  }
223 
232  public function updateRelationTableRow($tableName, array $fieldValues)
233  {
234  if (!isset($fieldValues['uid_local']) && !isset($fieldValues['uid_foreign'])) {
235  throw new \InvalidArgumentException(
236  'The given fieldValues must contain a value for "uid_local" and "uid_foreign".', 1360500126
237  );
238  }
239 
240  $where['uid_local'] = (int)$fieldValues['uid_local'];
241  $where['uid_foreign'] = (int)$fieldValues['uid_foreign'];
242  unset($fieldValues['uid_local']);
243  unset($fieldValues['uid_foreign']);
244 
245  if (!empty($fieldValues['tablenames'])) {
246  $where['tablenames'] = $fieldValues['tablenames'];
247  unset($fieldValues['tablenames']);
248  }
249  if (!empty($fieldValues['fieldname'])) {
250  $where['fieldname'] = $fieldValues['fieldname'];
251  unset($fieldValues['fieldname']);
252  }
253 
254  $updateSuccessful = $this->databaseHandle->exec_UPDATEquery(
255  $tableName,
256  $this->resolveWhereStatement($where, $tableName),
257  $fieldValues
258  );
259  $this->checkSqlErrors();
260 
261  return $updateSuccessful;
262  }
263 
272  public function removeRow($tableName, array $where, $isRelation = false)
273  {
274  $deleteSuccessful = $this->databaseHandle->exec_DELETEquery(
275  $tableName,
276  $this->resolveWhereStatement($where, $tableName)
277  );
278  $this->checkSqlErrors();
279 
280  if (!$isRelation && isset($where['uid'])) {
281  $this->clearPageCache($tableName, $where['uid']);
282  }
283 
284  return $deleteSuccessful;
285  }
286 
295  public function getMaxValueFromTable($tableName, array $where, $columnName)
296  {
297  $result = $this->databaseHandle->exec_SELECTgetSingleRow(
298  $columnName,
299  $tableName,
300  $this->resolveWhereStatement($where, $tableName),
301  '',
302  $columnName . ' DESC',
303  true
304  );
305  $this->checkSqlErrors();
306 
307  return $result[0];
308  }
309 
317  public function getRowByIdentifier($tableName, array $where)
318  {
319  $row = $this->databaseHandle->exec_SELECTgetSingleRow(
320  '*',
321  $tableName,
322  $this->resolveWhereStatement($where, $tableName)
323  );
324  $this->checkSqlErrors();
325 
326  return $row ?: false;
327  }
328 
337  protected function resolveWhereStatement(array $where, $tableName = 'foo')
338  {
339  $whereStatement = [];
340 
341  foreach ($where as $fieldName => $fieldValue) {
342  $whereStatement[] = $fieldName . ' = ' . $this->databaseHandle->fullQuoteStr($fieldValue, $tableName);
343  }
344 
345  return implode(' AND ', $whereStatement);
346  }
347 
354  public function getObjectDataByQuery(QueryInterface $query)
355  {
356  $statement = $query->getStatement();
357  if ($statement instanceof Qom\Statement) {
358  $rows = $this->getObjectDataByRawQuery($statement);
359  } else {
360  $rows = $this->getRowsByStatementParts($query);
361  }
362 
363  $rows = $this->doLanguageAndWorkspaceOverlay($query->getSource(), $rows, $query->getQuerySettings());
364  return $rows;
365  }
366 
375  protected function createQueryCommandParametersFromStatementParts(array $statementParts)
376  {
377  if (isset($statementParts['offset']) && !isset($statementParts['limit'])) {
378  throw new \InvalidArgumentException(
379  'Trying to make query with offset and no limit, the offset would become a limit. You have to set a limit to use offset. To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the limit.',
380  1465223252
381  );
382  }
383  return [
384  'selectFields' => implode(' ', $statementParts['keywords']) . ' ' . implode(',', $statementParts['fields']),
385  'fromTable' => implode(' ', $statementParts['tables']) . ' ' . implode(' ', $statementParts['unions']),
386  'whereClause' => (!empty($statementParts['where']) ? implode('', $statementParts['where']) : '1=1')
387  . (!empty($statementParts['additionalWhereClause'])
388  ? ' AND ' . implode(' AND ', $statementParts['additionalWhereClause'])
389  : ''
390  ),
391  'orderBy' => (!empty($statementParts['orderings']) ? implode(', ', $statementParts['orderings']) : ''),
392  'limit' => ($statementParts['offset'] ? $statementParts['offset'] . ', ' : '')
393  . ($statementParts['limit'] ? $statementParts['limit'] : '')
394  ];
395  }
396 
403  protected function getRowsByStatementParts(QueryInterface $query)
404  {
405  if ($query->getQuerySettings()->getUsePreparedStatement()) {
406  list($statementParts, $parameters) = $this->getStatementParts($query, false);
407  $rows = $this->getRowsFromPreparedDatabase($statementParts, $parameters);
408  } else {
409  list($statementParts) = $this->getStatementParts($query);
410  $rows = $this->getRowsFromDatabase($statementParts);
411  }
412 
413  return $rows;
414  }
415 
422  protected function getRowsFromDatabase(array $statementParts)
423  {
424  $queryCommandParameters = $this->createQueryCommandParametersFromStatementParts($statementParts);
425  $rows = $this->databaseHandle->exec_SELECTgetRows(
426  $queryCommandParameters['selectFields'],
427  $queryCommandParameters['fromTable'],
428  $queryCommandParameters['whereClause'],
429  '',
430  $queryCommandParameters['orderBy'],
431  $queryCommandParameters['limit']
432  );
433  $this->checkSqlErrors();
434 
435  return $rows;
436  }
437 
445  protected function getRowsFromPreparedDatabase(array $statementParts, array $parameters)
446  {
447  $queryCommandParameters = $this->createQueryCommandParametersFromStatementParts($statementParts);
448  $preparedStatement = $this->databaseHandle->prepare_SELECTquery(
449  $queryCommandParameters['selectFields'],
450  $queryCommandParameters['fromTable'],
451  $queryCommandParameters['whereClause'],
452  '',
453  $queryCommandParameters['orderBy'],
454  $queryCommandParameters['limit']
455  );
456 
457  $preparedStatement->execute($parameters);
458  $rows = $preparedStatement->fetchAll();
459 
460  $preparedStatement->free();
461  return $rows;
462  }
463 
470  protected function getObjectDataByRawQuery(Qom\Statement $statement)
471  {
472  $realStatement = $statement->getStatement();
473  $parameters = $statement->getBoundVariables();
474 
475  if ($realStatement instanceof \TYPO3\CMS\Core\Database\PreparedStatement) {
476  $realStatement->execute($parameters);
477  $rows = $realStatement->fetchAll();
478 
479  $realStatement->free();
480  } else {
481  $result = $this->databaseHandle->sql_query($realStatement);
482  $this->checkSqlErrors();
483 
484  $rows = [];
485  while ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
486  if (is_array($row)) {
487  $rows[] = $row;
488  }
489  }
490  $this->databaseHandle->sql_free_result($result);
491  }
492 
493  return $rows;
494  }
495 
503  public function getObjectCountByQuery(QueryInterface $query)
504  {
505  if ($query->getConstraint() instanceof Qom\Statement) {
506  throw new Exception\BadConstraintException('Could not execute count on queries with a constraint of type TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Statement', 1256661045);
507  }
508 
509  list($statementParts) = $this->getStatementParts($query);
510 
511  $fields = '*';
512  if (isset($statementParts['keywords']['distinct'])) {
513  $fields = 'DISTINCT ' . reset($statementParts['tables']) . '.uid';
514  }
515 
516  $queryCommandParameters = $this->createQueryCommandParametersFromStatementParts($statementParts);
517  $count = $this->databaseHandle->exec_SELECTcountRows(
518  $fields,
519  $queryCommandParameters['fromTable'],
520  $queryCommandParameters['whereClause']
521  );
522  $this->checkSqlErrors();
523 
524  if ($statementParts['offset']) {
525  $count -= $statementParts['offset'];
526  }
527 
528  if ($statementParts['limit']) {
529  $count = min($count, $statementParts['limit']);
530  }
531 
532  return (int)max(0, $count);
533  }
534 
543  protected function getStatementParts($query, $resolveParameterPlaceholders = true)
544  {
554  list($queryHash, $parameters) = $this->queryParser->preparseQuery($query);
555 
556  if ($query->getQuerySettings()->getUseQueryCache()) {
557  $statementParts = $this->getQueryCacheEntry($queryHash);
558  if ($queryHash && !$statementParts) {
559  $statementParts = $this->queryParser->parseQuery($query);
560  $this->setQueryCacheEntry($queryHash, $statementParts);
561  }
562  } else {
563  $statementParts = $this->queryParser->parseQuery($query);
564  }
565 
566  if (!$statementParts) {
567  throw new \RuntimeException('Your query could not be built.', 1394453197);
568  }
569 
570  $this->queryParser->addDynamicQueryParts($query->getQuerySettings(), $statementParts);
571 
572  // Limit and offset are not cached to allow caching of pagebrowser queries.
573  $statementParts['limit'] = ((int)$query->getLimit() ?: null);
574  $statementParts['offset'] = ((int)$query->getOffset() ?: null);
575 
576  if ($resolveParameterPlaceholders === true) {
577  $statementParts = $this->resolveParameterPlaceholders($statementParts, $parameters);
578  }
579 
580  return [$statementParts, $parameters];
581  }
582 
590  protected function resolveParameterPlaceholders(array $statementParts, array $parameters)
591  {
592  $tableName = reset($statementParts['tables']) ?: 'foo';
593 
594  foreach ($parameters as $parameterPlaceholder => $parameter) {
595  $parameter = $this->dataMapper->getPlainValue($parameter, null, [$this, 'quoteTextValueCallback'], ['tablename' => $tableName]);
596  $statementParts['where'] = str_replace($parameterPlaceholder, $parameter, $statementParts['where']);
597  }
598 
599  return $statementParts;
600  }
601 
609  public function quoteTextValueCallback($value, $parameters)
610  {
611  return $this->databaseHandle->fullQuoteStr($value, $parameters['tablename']);
612  }
613 
622  {
623  $fields = [];
624  $parameters = [];
625  $dataMap = $this->dataMapper->getDataMap(get_class($object));
626  $properties = $object->_getProperties();
627  foreach ($properties as $propertyName => $propertyValue) {
628  // @todo We couple the Backend to the Entity implementation (uid, isClone); changes there breaks this method
629  if ($dataMap->isPersistableProperty($propertyName) && $propertyName !== 'uid' && $propertyName !== 'pid' && $propertyName !== 'isClone') {
630  if ($propertyValue === null) {
631  $fields[] = $dataMap->getColumnMap($propertyName)->getColumnName() . ' IS NULL';
632  } else {
633  $fields[] = $dataMap->getColumnMap($propertyName)->getColumnName() . '=?';
634  $parameters[] = $this->dataMapper->getPlainValue($propertyValue);
635  }
636  }
637  }
638  $sql = [];
639  $sql['additionalWhereClause'] = [];
640  $tableName = $dataMap->getTableName();
641  $this->addVisibilityConstraintStatement(new Typo3QuerySettings(), $tableName, $sql);
642  $statement = 'SELECT * FROM ' . $tableName;
643  $statement .= ' WHERE ' . implode(' AND ', $fields);
644  if (!empty($sql['additionalWhereClause'])) {
645  $statement .= ' AND ' . implode(' AND ', $sql['additionalWhereClause']);
646  }
647  $this->replacePlaceholders($statement, $parameters, $tableName);
648  // debug($statement,-2);
649  $res = $this->databaseHandle->sql_query($statement);
650  $this->checkSqlErrors($statement);
651  $row = $this->databaseHandle->sql_fetch_assoc($res);
652  if ($row !== false) {
653  return (int)$row['uid'];
654  } else {
655  return false;
656  }
657  }
658 
671  protected function replacePlaceholders(&$sqlString, array $parameters, $tableName = 'foo')
672  {
673  // @todo profile this method again
674  if (substr_count($sqlString, '?') !== count($parameters)) {
675  throw new Exception('The number of question marks to replace must be equal to the number of parameters.', 1242816074);
676  }
677  $offset = 0;
678  foreach ($parameters as $parameter) {
679  $markPosition = strpos($sqlString, '?', $offset);
680  if ($markPosition !== false) {
681  if ($parameter === null) {
682  $parameter = 'NULL';
683  } elseif (is_array($parameter) || $parameter instanceof \ArrayAccess || $parameter instanceof \Traversable) {
684  $items = [];
685  foreach ($parameter as $item) {
686  $items[] = $this->databaseHandle->fullQuoteStr($item, $tableName);
687  }
688  $parameter = '(' . implode(',', $items) . ')';
689  } else {
690  $parameter = $this->databaseHandle->fullQuoteStr($parameter, $tableName);
691  }
692  $sqlString = substr($sqlString, 0, $markPosition) . $parameter . substr($sqlString, ($markPosition + 1));
693  }
694  $offset = $markPosition + strlen($parameter);
695  }
696  }
697 
707  protected function addVisibilityConstraintStatement(QuerySettingsInterface $querySettings, $tableName, array &$sql)
708  {
709  $statement = '';
710  if (is_array($GLOBALS['TCA'][$tableName]['ctrl'])) {
711  $ignoreEnableFields = $querySettings->getIgnoreEnableFields();
712  $enableFieldsToBeIgnored = $querySettings->getEnableFieldsToBeIgnored();
713  $includeDeleted = $querySettings->getIncludeDeleted();
714  if ($this->environmentService->isEnvironmentInFrontendMode()) {
715  $statement .= $this->getFrontendConstraintStatement($tableName, $ignoreEnableFields, $enableFieldsToBeIgnored, $includeDeleted);
716  } else {
717  // TYPO3_MODE === 'BE'
718  $statement .= $this->getBackendConstraintStatement($tableName, $ignoreEnableFields, $includeDeleted);
719  }
720  if (!empty($statement)) {
721  $statement = strtolower(substr($statement, 1, 3)) === 'and' ? substr($statement, 5) : $statement;
722  $sql['additionalWhereClause'][] = $statement;
723  }
724  }
725  }
726 
738  protected function getFrontendConstraintStatement($tableName, $ignoreEnableFields, array $enableFieldsToBeIgnored = [], $includeDeleted)
739  {
740  $statement = '';
741  if ($ignoreEnableFields && !$includeDeleted) {
742  if (!empty($enableFieldsToBeIgnored)) {
743  // array_combine() is necessary because of the way \TYPO3\CMS\Frontend\Page\PageRepository::enableFields() is implemented
744  $statement .= $this->getPageRepository()->enableFields($tableName, -1, array_combine($enableFieldsToBeIgnored, $enableFieldsToBeIgnored));
745  } else {
746  $statement .= $this->getPageRepository()->deleteClause($tableName);
747  }
748  } elseif (!$ignoreEnableFields && !$includeDeleted) {
749  $statement .= $this->getPageRepository()->enableFields($tableName);
750  } elseif (!$ignoreEnableFields && $includeDeleted) {
751  throw new Exception\InconsistentQuerySettingsException('Query setting "ignoreEnableFields=FALSE" can not be used together with "includeDeleted=TRUE" in frontend context.', 1327678173);
752  }
753  return $statement;
754  }
755 
765  protected function getBackendConstraintStatement($tableName, $ignoreEnableFields, $includeDeleted)
766  {
767  $statement = '';
768  if (!$ignoreEnableFields) {
769  $statement .= BackendUtility::BEenableFields($tableName);
770  }
771  if (!$includeDeleted) {
772  $statement .= BackendUtility::deleteClause($tableName);
773  }
774  return $statement;
775  }
776 
787  protected function doLanguageAndWorkspaceOverlay(Qom\SourceInterface $source, array $rows, QuerySettingsInterface $querySettings, $workspaceUid = null)
788  {
789  if ($source instanceof Qom\SelectorInterface) {
790  $tableName = $source->getSelectorName();
791  } elseif ($source instanceof Qom\JoinInterface) {
792  $tableName = $source->getRight()->getSelectorName();
793  } else {
794  // No proper source, so we do not have a table name here
795  // we cannot do an overlay and return the original rows instead.
796  return $rows;
797  }
798 
800  if (is_object($this->getTSFE())) {
801  if ($workspaceUid !== null) {
802  $pageRepository->versioningWorkspaceId = $workspaceUid;
803  }
804  } else {
805  if ($workspaceUid === null) {
806  $workspaceUid = $this->getBeUser()->workspace;
807  }
808  $pageRepository->versioningWorkspaceId = $workspaceUid;
809  }
810 
811  // Fetches the move-placeholder in case it is supported
812  // by the table and if there's only one row in the result set
813  // (applying this to all rows does not work, since the sorting
814  // order would be destroyed and possible limits not met anymore)
815  if (!empty($pageRepository->versioningWorkspaceId)
817  && count($rows) === 1
818  ) {
819  $movePlaceholder = $this->databaseHandle->exec_SELECTgetSingleRow(
820  $tableName . '.*',
821  $tableName,
822  't3ver_state=3 AND t3ver_wsid=' . $pageRepository->versioningWorkspaceId
823  . ' AND t3ver_move_id=' . $rows[0]['uid']
824  );
825  if (!empty($movePlaceholder)) {
826  $rows = [$movePlaceholder];
827  }
828  }
829 
830  $overlaidRows = [];
831  foreach ($rows as $row) {
832  // If current row is a translation select its parent
833  if (isset($tableName) && isset($GLOBALS['TCA'][$tableName])
834  && isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
835  && isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
836  && !isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerTable'])
837  ) {
838  if (isset($row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']])
839  && $row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] > 0
840  ) {
841  $row = $this->databaseHandle->exec_SELECTgetSingleRow(
842  $tableName . '.*',
843  $tableName,
844  $tableName . '.uid=' . (int)$row[$GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']] .
845  ' AND ' . $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . '=0'
846  );
847  }
848  }
849  $pageRepository->versionOL($tableName, $row, true);
850  if ($tableName == 'pages') {
851  $row = $pageRepository->getPageOverlay($row, $querySettings->getLanguageUid());
852  } elseif (isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
853  && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== ''
854  && !isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerTable'])
855  ) {
856  if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']], [-1, 0])) {
857  $overlayMode = $querySettings->getLanguageMode() === 'strict' ? 'hideNonTranslated' : '';
858  $row = $pageRepository->getRecordOverlay($tableName, $row, $querySettings->getLanguageUid(), $overlayMode);
859  }
860  }
861  if ($row !== null && is_array($row)) {
862  $overlaidRows[] = $row;
863  }
864  }
865  return $overlaidRows;
866  }
867 
871  protected function getPageRepository()
872  {
873  if (!$this->pageRepository instanceof PageRepository) {
874  if ($this->environmentService->isEnvironmentInFrontendMode() && is_object($this->getTSFE())) {
875  $this->pageRepository = $this->getTSFE()->sys_page;
876  } else {
877  $this->pageRepository = GeneralUtility::makeInstance(PageRepository::class);
878  }
879  }
880 
881  return $this->pageRepository;
882  }
883 
891  protected function checkSqlErrors($sql = '')
892  {
893  $error = $this->databaseHandle->sql_error();
894  if ($error !== '') {
895  $error .= $sql ? ': ' . $sql : '';
896  throw new SqlErrorException($error, 1247602160);
897  }
898  }
899 
911  protected function clearPageCache($tableName, $uid)
912  {
913  $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
914  if (isset($frameworkConfiguration['persistence']['enableAutomaticCacheClearing']) && $frameworkConfiguration['persistence']['enableAutomaticCacheClearing'] === '1') {
915  } else {
916  // if disabled, return
917  return;
918  }
919  $pageIdsToClear = [];
920  $storagePage = null;
921  $columns = $this->databaseHandle->admin_get_fields($tableName);
922  $tsfe = $this->getTSFE();
923  if (array_key_exists('pid', $columns)) {
924  $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid=' . (int)$uid);
925  if ($row = $this->databaseHandle->sql_fetch_assoc($result)) {
926  $storagePage = $row['pid'];
927  $pageIdsToClear[] = $storagePage;
928  }
929  } elseif (isset($tsfe)) {
930  // No PID column - we can do a best-effort to clear the cache of the current page if in FE
931  $storagePage = $tsfe->id;
932  $pageIdsToClear[] = $storagePage;
933  }
934  if ($storagePage === null) {
935  return;
936  }
937  if (!isset($this->pageTSConfigCache[$storagePage])) {
938  $this->pageTSConfigCache[$storagePage] = BackendUtility::getPagesTSconfig($storagePage);
939  }
940  if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) {
941  $clearCacheCommands = GeneralUtility::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), true);
942  $clearCacheCommands = array_unique($clearCacheCommands);
943  foreach ($clearCacheCommands as $clearCacheCommand) {
944  if (MathUtility::canBeInterpretedAsInteger($clearCacheCommand)) {
945  $pageIdsToClear[] = $clearCacheCommand;
946  }
947  }
948  }
949 
950  foreach ($pageIdsToClear as $pageIdToClear) {
951  $this->cacheService->getPageIdStack()->push($pageIdToClear);
952  }
953  }
954 
961  protected function getQueryCacheEntry($entryIdentifier)
962  {
963  if (!isset($this->queryRuntimeCache[$entryIdentifier])) {
964  $this->queryRuntimeCache[$entryIdentifier] = $this->queryCache->get($entryIdentifier);
965  }
966  return $this->queryRuntimeCache[$entryIdentifier];
967  }
968 
976  protected function setQueryCacheEntry($entryIdentifier, $variable)
977  {
978  $this->queryRuntimeCache[$entryIdentifier] = $variable;
979  $this->queryCache->set($entryIdentifier, $variable, [], 0);
980  }
981 
985  protected function getTSFE()
986  {
987  return isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : null;
988  }
989 
993  protected function getBeUser()
994  {
995  return isset($GLOBALS['BE_USER']) ? $GLOBALS['BE_USER'] : null;
996  }
997 }
static getPagesTSconfig($id, $rootLine=null, $returnPartArray=false)
injectEnvironmentService(EnvironmentService $environmentService)
doLanguageAndWorkspaceOverlay(Qom\SourceInterface $source, array $rows, QuerySettingsInterface $querySettings, $workspaceUid=null)
resolveParameterPlaceholders(array $statementParts, array $parameters)
injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
addVisibilityConstraintStatement(QuerySettingsInterface $querySettings, $tableName, array &$sql)
getStatementParts($query, $resolveParameterPlaceholders=true)
static BEenableFields($table, $inv=false)
replacePlaceholders(&$sqlString, array $parameters, $tableName='foo')
getBackendConstraintStatement($tableName, $ignoreEnableFields, $includeDeleted)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
addRow($tableName, array $fieldValues, $isRelation=false)
getFrontendConstraintStatement($tableName, $ignoreEnableFields, array $enableFieldsToBeIgnored=[], $includeDeleted)
$uid
Definition: server.php:38
updateRow($tableName, array $fieldValues, $isRelation=false)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
$sql
Definition: server.php:84
getMaxValueFromTable($tableName, array $where, $columnName)
removeRow($tableName, array $where, $isRelation=false)
static deleteClause($table, $tableAlias='')
getRowsFromPreparedDatabase(array $statementParts, array $parameters)