Bug #79615
closedQueryRestrictionBuilder restrictions not working when using table multiple times in one query
100%
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.