-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
The methods of this service are used often. For example the media extension makes wide usage in the backend. The DataHandlerHook of the media extension might query the sys_file_reference table if a record with file references is saved. Now if one of those references is hidden the exception "There is something broken with the File References. Consider updating the Reference Index." is occuring because the getRecord() method of the DataService can't find the reference because it's hidden.
I think the method DataService::getQueryBuilder() should look like this:
...
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction;
...
/**
* @param string $tableName
* @return object|QueryBuilder
*/
protected function getQueryBuilder($tableName): QueryBuilder
{
/** @var ConnectionPool $connectionPool */
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable($tableName);
if ($this->isBackendMode()) {
$queryBuilder
->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
}
if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['versioningWS'])) {
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(
$this->isBackendMode() ? BackendWorkspaceRestriction::class : FrontendWorkspaceRestriction::class
));
}
return $queryBuilder;
}
/**
* Returns whether the current mode is Backend.
*
* @return bool
*/
protected function isBackendMode()
{
return TYPO3_MODE == 'BE';
}
I'm willing to provide this as a pull request.
Metadata
Metadata
Assignees
Labels
No labels