‪TYPO3CMS  11.5
TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction Class Reference
Inheritance diagram for TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction:

Public Member Functions

 __construct (int $workspaceId=0, bool $includeAllVersionedRecords=false)
CompositeExpression buildExpression (array $queriedTables, ExpressionBuilder $expressionBuilder)

Protected Attributes

int $workspaceId
bool $includeAllVersionedRecords

Detailed Description

Restriction to make queries workspace-aware. This restriction is new compared to the "older" FrontendWorkspaceRestriction and BackendWorkspaceRestriction in a way that it ALWAYS fetches the live version, plus in current workspace the workspace records). It does not care about the state, as this should be done by overlays.

As workspaces cannot be fully overlaid within ONE query, this query does the following:

  • ‪In live context, only fetch published records
  • ‪In a workspace, fetch all LIVE records and all workspace records which do not have "1" (= all new placeholders get fetched as well)

This means, that all records which are fetched need to run through either

  • ‪BackendUtility::getRecordWSOL() (when having one or a few records)
  • ‪PageRepository->versionOL()
  • ‪PlainDataResolver (when having lots of records)

Definition at line 39 of file WorkspaceRestriction.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction::__construct ( int  $workspaceId = 0,
bool  $includeAllVersionedRecords = false 

Member Function Documentation

◆ buildExpression()

CompositeExpression TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction::buildExpression ( array  $queriedTables,
ExpressionBuilder  $expressionBuilder 

Main method to build expressions for given tables

array$queriedTables‪Array of tables, where array key is table alias and value is a table name
ExpressionBuilder$expressionBuilderExpression builder instance to add restrictions with
‪CompositeExpression The result of query builder expression(s)

Implements TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionInterface.

Definition at line 65 of file WorkspaceRestriction.php.

References $GLOBALS, TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\andX(), TYPO3\CMS\Core\Versioning\VersionState\DELETE_PLACEHOLDER, TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\eq(), TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\in(), TYPO3\CMS\Core\Versioning\VersionState\MOVE_POINTER, TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\neq(), and TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\orX().

Member Data Documentation

◆ $includeAllVersionedRecords

bool TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction::$includeAllVersionedRecords

Used to also query records within a workspace, which is useful for DB queries that check for a specific field (e.g. "slug") which might have changed within a workspace. Please note that some duplicates might be shown and the "reduce" logic needs to be added after querying. Setting this flag might also be a problem when using the DB query with limit and offset settings.

Definition at line 50 of file WorkspaceRestriction.php.

Referenced by TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction\__construct().

◆ $workspaceId

int TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction::$workspaceId