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
*/
public function findByStorageType($storageType) {
$storageObjects = array();
*/
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);
}
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$storageObjects[] = $this->createDomainObject($row);
}
*/
public function findAll() {
$storageObjects = array();
*/
public function findAll() {
$storageObjects = array();
- $whereClause = 'deleted=0 AND hidden=0';
- $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);
}
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$storageObjects[] = $this->createDomainObject($row);
}
return $this->factory->getStorageObject($databaseRow['uid'], $databaseRow);
}
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;
+ }