From: Benjamin Mack Date: Tue, 9 Oct 2012 14:27:34 +0000 (+0200) Subject: [BUGFIX] FAL storage repo uses hard-coded enableFields X-Git-Tag: TYPO3_6-0-0rc1~187 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/c799ea9a9db6e794816fed7a1f27aab38e7b5d3d [BUGFIX] FAL storage repo uses hard-coded enableFields The storage repository has hardcoded SQL where clauses for deleted and hidden. Solution: Create a new function that returns the additional where clause, based on the frontend / backend context. Change-Id: I6258ee639d4cc8d97a9712596baeb86ea1e576b6 Resolves: #41715 Releases: 6.0 Reviewed-on: http://review.typo3.org/15445 Reviewed-by: Steffen Ritter Tested-by: Steffen Ritter --- diff --git a/typo3/sysext/core/Classes/Resource/StorageRepository.php b/typo3/sysext/core/Classes/Resource/StorageRepository.php index 4eeb23e28b6..6eeec4c311f 100644 --- a/typo3/sysext/core/Classes/Resource/StorageRepository.php +++ b/typo3/sysext/core/Classes/Resource/StorageRepository.php @@ -59,9 +59,12 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\AbstractRepository { */ public function findByStorageType($storageType) { $storageObjects = array(); - $whereClause = 'deleted=0 AND hidden=0'; - $whereClause .= ' AND ' . $this->typeField . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($storageType, $this->table); - $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->table, $whereClause); + $whereClause = $this->typeField . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($storageType, $this->table); + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( + '*', + $this->table, + $whereClause . $this->getWhereClauseForEnabledFields() + ); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $storageObjects[] = $this->createDomainObject($row); } @@ -77,11 +80,15 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\AbstractRepository { */ public function findAll() { $storageObjects = array(); - $whereClause = 'deleted=0 AND hidden=0'; + $whereClause = NULL; if ($this->type != '') { - $whereClause .= ' AND ' . $this->typeField . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->type, $this->table); + $whereClause = $this->typeField . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->type, $this->table); } - $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->table, $whereClause); + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( + '*', + $this->table, + ($whereClause ? $whereClause : '1=1') . $this->getWhereClauseForEnabledFields() + ); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $storageObjects[] = $this->createDomainObject($row); } @@ -144,6 +151,22 @@ class StorageRepository extends \TYPO3\CMS\Core\Resource\AbstractRepository { return $this->factory->getStorageObject($databaseRow['uid'], $databaseRow); } + /** + * get the WHERE clause for the enabled fields of this TCA table + * depending on the context + * + * @return string the additional where clause, something like " AND deleted=0 AND hidden=0" + */ + protected function getWhereClauseForEnabledFields() { + if (is_object($GLOBALS['TSFE'])) { + // frontend context + $whereClause = $GLOBALS['TSFE']->sys_page->enableFields($this->table); + } else { + // backend context + $whereClause = \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($this->table); + } + return $whereClause; + } }