Bug #93484 » Typo3DbBackend.php.patch
Typo3DbBackend.issue-93484.php 2021-02-11 11:28:41.998962822 +0100 | ||
---|---|---|
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\Qom;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\Join;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\Query;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
|
||
use TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\BadConstraintException;
|
||
... | ... | |
*
|
||
* @param QueryInterface $query
|
||
* @return array
|
||
* @throws SqlErrorException
|
||
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
|
||
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception
|
||
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException
|
||
*/
|
||
public function getObjectDataByQuery(QueryInterface $query)
|
||
{
|
||
... | ... | |
}
|
||
}
|
||
$querySource = $query->getSource();
|
||
$tableName = $this->resolveWorkspaceOverlaySource($querySource, $query);
|
||
if ($tableName === false) {
|
||
// No proper source, so we do not have a table name here
|
||
// we cannot do an overlay and return the original rows instead.
|
||
return $rows;
|
||
} else if ($querySource instanceof Qom\JoinInterface) {
|
||
// Flatten Source to simple Select
|
||
$qob = $this->objectManager->get(QueryObjectModelFactory::class);
|
||
$querySource = $qob->selector($tableName, $query->getType());
|
||
}
|
||
if ($this->configurationManager->isFeatureEnabled('consistentTranslationOverlayHandling') && !empty($rows)) {
|
||
$rows = $this->overlayLanguageAndWorkspace($query->getSource(), $rows, $query);
|
||
$rows = $this->overlayLanguageAndWorkspace($querySource, $rows, $query);
|
||
} else {
|
||
$rows = $this->doLanguageAndWorkspaceOverlay($query->getSource(), $rows, $query->getQuerySettings());
|
||
$rows = $this->doLanguageAndWorkspaceOverlay($querySource, $rows, $query->getQuerySettings());
|
||
}
|
||
return $rows;
|
||
... | ... | |
* @param QuerySettingsInterface $querySettings The TYPO3 CMS specific query settings
|
||
* @param int|null $workspaceUid
|
||
* @return array
|
||
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
|
||
*/
|
||
protected function doLanguageAndWorkspaceOverlay(Qom\SourceInterface $source, array $rows, QuerySettingsInterface $querySettings, $workspaceUid = null)
|
||
{
|
||
if ($source instanceof Qom\SelectorInterface) {
|
||
$tableName = $source->getSelectorName();
|
||
} elseif ($source instanceof Qom\JoinInterface) {
|
||
$tableName = $source->getRight()->getSelectorName();
|
||
} else {
|
||
// No proper source, so we do not have a table name here
|
||
// we cannot do an overlay and return the original rows instead.
|
||
... | ... | |
* @param int|null $workspaceUid
|
||
* @return array
|
||
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
|
||
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception
|
||
*/
|
||
protected function overlayLanguageAndWorkspace(Qom\SourceInterface $source, array $rows, QueryInterface $query, int $workspaceUid = null): array
|
||
protected function overlayLanguageAndWorkspace(Qom\SourceInterface &$source, array $rows, QueryInterface $query, int $workspaceUid = null): array
|
||
{
|
||
if ($source instanceof Qom\SelectorInterface) {
|
||
$tableName = $source->getSelectorName();
|
||
} elseif ($source instanceof Qom\JoinInterface) {
|
||
$tableName = $source->getRight()->getSelectorName();
|
||
} else {
|
||
// No proper source, so we do not have a table name here
|
||
// we cannot do an overlay and return the original rows instead.
|
||
... | ... | |
}
|
||
/**
|
||
* Bugfix issue #93484
|
||
* https://forge.typo3.org/issues/93484#change-439640
|
||
*
|
||
* @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source
|
||
* @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
|
||
* @return bool
|
||
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception
|
||
*/
|
||
protected function resolveWorkspaceOverlaySource(SourceInterface $source, QueryInterface $query) :? string {
|
||
$tableName = null;
|
||
if ($source instanceof Qom\SelectorInterface) {
|
||
$tableName = $source->getSelectorName();
|
||
} elseif ($source instanceof Qom\JoinInterface) {
|
||
/**
|
||
* Bugfix issue #93484
|
||
* https://forge.typo3.org/issues/93484#change-439640
|
||
*
|
||
* Derive Table-Name from Model-Name
|
||
*/
|
||
$modelName = $query->getType();
|
||
$modelName = '\\' . ltrim($modelName, '\\');
|
||
$dataMapper = $this->objectManager->get(DataMapper::class);
|
||
$tableName = $dataMapper->getDataMap($modelName)->getTableName();
|
||
}
|
||
return $tableName;
|
||
}
|
||
/**
|
||
* Clear the TYPO3 page cache for the given record.
|
||
* If the record lies on a page, then we clear the cache of this page.
|
||
* If the record has no PID column, we clear the cache of the current page as best-effort.
|
- « Previous
- 1
- 2
- Next »