Project

General

Profile

Actions

Bug #79615

closed

QueryRestrictionBuilder restrictions not working when using table multiple times in one query

Added by Patrick Broens about 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
Start date:
2017-02-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
Stabilization Sprint

Description

For several reasons it is sometimes necessary to join a table in a single query which is used before. This can be in ->from() or another ->join().

When using a statement like

$statement = $queryBuilder
            ->select('original.*')
            ->from('pages', 'original')
            ->join(
                'original',
                'pages',
                'similar',
                $queryBuilder->expr()->eq(
                    'similar.uid',
                    <PUT_SOME_UID_HERE>
                )
            )
            ...

or joining the same table multiple times will only add the restrictions for the last mentioned table.

This is due to the fact the method "getQueriedTables()" in the "QueryBuilder" does not take multiple use of a single table into account. The array returned from this method will look like

[
            'pages' => 'similar'
]

while it should be multidimensional like

[
            'pages' => [
                        'original'
                        'similar'
            ]
]

While setting this array it will overwrite the alias "original" with the second one "similar".

The RestrictionBuilder is using this array to iterate over all tables setting their restrictions, which fails for "original". The RestrictionBuilder should also take into account there can be multiple use of one table, using the multidimensional array.

Actions

Also available in: Atom PDF