Skip to content

Commit

Permalink
[BUGFIX] Have backend layouts in DB respect workspace versions
Browse files Browse the repository at this point in the history
Resolves: #24737
Releases: master, 9.5
Change-Id: I5a5f1b0a26951266a0e90c46af670602247693e5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62214
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
bmack committed Nov 6, 2019
1 parent a6af4fd commit 9b09fae
Showing 1 changed file with 20 additions and 11 deletions.
Expand Up @@ -14,8 +14,11 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -70,14 +73,7 @@ public function getBackendLayout($identifier, $pageId)
return $this->createDefaultBackendLayout();
}

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($this->tableName);
$data = $queryBuilder
->select('*')
->from($this->tableName)
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($identifier, \PDO::PARAM_INT)))
->execute()
->fetch();
$data = BackendUtility::getRecordWSOL($this->tableName, $identifier);

if (is_array($data)) {
$backendLayout = $this->createBackendLayout($data);
Expand Down Expand Up @@ -147,6 +143,13 @@ protected function getLayoutData($fieldName, array $pageTsConfig, $pageUid)
// Add layout records
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($this->tableName);
$queryBuilder->getRestrictions()
->add(
GeneralUtility::makeInstance(
WorkspaceRestriction::class,
GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('workspace', 'id')
)
);
$queryBuilder
->select('*')
->from($this->tableName)
Expand Down Expand Up @@ -192,9 +195,15 @@ protected function getLayoutData($fieldName, array $pageTsConfig, $pageUid)
$queryBuilder->orderBy($GLOBALS['TCA'][$this->tableName]['ctrl']['sortby']);
}

$results = $queryBuilder
->execute()
->fetchAll();
$statement = $queryBuilder->execute();

$results = [];
while ($record = $statement->fetch()) {
BackendUtility::workspaceOL($this->tableName, $record);
if (is_array($record)) {
$results[$record['t3ver_oid'] ?: $record['uid']] = $record;
}
}

return $results;
}
Expand Down

0 comments on commit 9b09fae

Please sign in to comment.