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.
Updated by Patrick Broens almost 8 years ago
- Target version changed from 8.6 to 8 LTS
Updated by Josef Glatz over 7 years ago
- Sprint Focus set to Stabilization Sprint
Updated by Tymoteusz Motylewski over 7 years ago
This issue is e.g. present in LocalizationRepository::fetchOriginLanguage
The query there is inner joining tt_content with self (alias tt_content_orig) which results in delete where clause being added only for tt_content_orig and not for tt_content.
Updated by Gerrit Code Review over 7 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51902
Updated by Gerrit Code Review over 7 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51902
Updated by Gerrit Code Review over 7 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51902
Updated by Gerrit Code Review over 7 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51902
Updated by Tymoteusz Motylewski over 7 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset aa3396080bc70d9ee15c3dbff9a6a9dc4c79204f.
Updated by Gerrit Code Review over 7 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51912
Updated by Gerrit Code Review over 7 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51912
Updated by Gerrit Code Review over 7 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51912
Updated by Tymoteusz Motylewski over 7 years ago
- Status changed from Under Review to Resolved
Applied in changeset f85326d380256bf8ad1dcbd78a7e042898bc69d7.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed