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

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 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 38 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

Parameters
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
Returns
‪CompositeExpression The result of query builder expression(s)

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

Definition at line 64 of file WorkspaceRestriction.php.

References $GLOBALS, TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\and(), TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\eq(), TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\in(), TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\neq(), and TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder\or().

Member Data Documentation

◆ $includeAllVersionedRecords

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

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 49 of file WorkspaceRestriction.php.

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

◆ $workspaceId

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