Bug #69481
closedRepository ignoreEnableFields does not work in frontend mode
0%
Description
The possibility to ignore enable fields, such as the hidden field, does not work in frontend mode, because it is ignored by the getFrontendConstraintStatement in TYPO3DbQueryParser. As one can define to ignore the enable fields in the repository, the core should be listening to this and give the hidden record to the repository, even in frontend mode, because the developer has intentionally declared this query setting inside the repository.
The only workaround at this moment is, to define another "hidden" field, that can be read in frontend mode.
I am on TYPO3 6.2.14
Updated by Morton Jonuschat about 9 years ago
- Status changed from New to Needs Feedback
Can you give some more information on what you are trying to do and where it fails? I tried to reproduce with a custom method in a repository that uses setIgnoreEnableFields() and everythings works as expected.
Updated by Kevin Ditscheid about 9 years ago
Shure, i created a normal repository and inserted a function, that will fetch the hidden records:
/** * Finds records with the given emailWildcard, includes hidden records * * @param string $emailWildcard * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ public function findByEmailWildcardWithHidden($emailWildcard){ $query = $this->createQuery(); $querySettings = $query->getQuerySettings(); $querySettings->setIgnoreEnableFields(TRUE); $querySettings->setEnableFieldsToBeIgnored(array('hidden')); $query->setQuerySettings($querySettings); return $query->matching($query->equals('emailWildcard', $emailWildcard))->execute(); }
I excluded the storage page by default:
/** * Initializes the blacklist repository */ public function initializeObject(){ /** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */ $defaultQuerySettings = $this->objectManager->get('\\TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings'); // don't add the pid constraint $defaultQuerySettings->setRespectStoragePage(FALSE); $this->setDefaultQuerySettings($defaultQuerySettings); }
And called the repository method in the controller like so:
$blacklistEntry = $this->blacklistRepository->findByEmailWildcardWithHidden($vote->getEmail()); if($blacklistEntry->count() <= 0){ $blacklistEntry = $this->objectManager->get('\EngineProductions\EpAwards\Domain\Model\Blacklist'); $blacklistEntry->setHidden(TRUE); $blacklistEntry->setEmailWildcard($vote->getEmail()); $this->blacklistRepository->add($blacklistEntry); }
I would like to check, if a blacklist entry for the submitted email address is present, even if it is hidden. In my opinion this should work, because i excluded the hidden field inside the repository find-method, but when the query fires, inside the getFrontendConstraintStatement method, the following line leads to the exclusion of hidden fields.
$statement .= $this->getPageRepository()->enableFields($tableName, -1, array_combine($enableFieldsToBeIgnored, $enableFieldsToBeIgnored));
It seems the function enableFields inside of \TYPO3\CMS\Frontend\Page\PageRepository does not recognize the hidden field exclusion, because it is only listening to the $show_hidden parameter, that is set to - 1. So i can only show the hidden records, if i switch $GLOBALS['TSFE']->showHiddenRecords to true, but i don't want to show all hidden records globaly, but only the ones, that i select with my query in the repository.
Updated by Alexander Opitz about 9 years ago
$querySettings->setIgnoreEnableFields(TRUE); $querySettings->setEnableFieldsToBeIgnored(array('hidden'));
Do you have more Enable fields beside the hidden field?
Updated by Kevin Ditscheid about 9 years ago
The default ones, starttime and endtime, but both aren't set for the records.
Updated by Alexander Opitz about 9 years ago
There are two ways to ignore enable fields.
- Ignore ALL enable fields
$querySettings->setIgnoreEnableFields(TRUE);
- Ignore ONLY SOME enable fields
$querySettings->setIgnoreEnableFields(TRUE); $querySettings->setEnableFieldsToBeIgnored(array(namesOfTheConfiguredField));
The namesOfTheConfiguredField is the name in the ctrl section from your TCA and not the name of the field in the database.
For your code this means you should write 'disabled' instead of 'hidden'.
Updated by Kevin Ditscheid about 9 years ago
Aha, so this was just a misunderstanding of the functionality. My bad, This ticket can be closed then, because it's working.
Updated by Alexander Opitz about 9 years ago
- Status changed from Needs Feedback to Closed
No problem, thanks for your feedback.