Review main Merged

60781[FEATURE] Add restriction container that limits applicable tables

Helmut Hummel CR +2 V +2 Hard +393 −0 updated 04/17/20, 18:23

Commit message

It is now possible to limit restrictions to a given set of table aliases
by using the introduced
\TYPO3\CMS\Core\Database\Query\Restriction\LimitToTablesRestrictionContainer.

Example:

$queryBuilder->getRestrictions()
    ->removeByType(HiddenRestriction::class)
    ->add(
        GeneralUtility::makeInstance(LimitToTablesRestrictionContainer::class)
            ->addForTables(
                GeneralUtility::makeInstance(HiddenRestriction::class),
                ['sys_language']
             );

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Markus Klein +1
    • Manuel Selbach +1
    • Andreas Kienast +1
  • Verified V +2 Done
    • Benni Mack +2
    • Manuel Selbach +1
    • TYPO3com +1 CI

Issues 1

Files 5

Review log 4877

Show 2852 earlier messages
  1. Helmut Hummel uploaded patch set 1 05/20/19, 12:38

  2. Helmut Hummel uploaded patch set 2 05/20/19, 12:41

  3. Mathias Brodala commented on patch set 2 05/20/19, 12:43

    Feature-87776-LimitRestrictionToTablesInQueryBuilder.rst:24

    What do you think about adding an "addForTableAlias()" instead and keeping the "RestrictionsForTableAliases" internal?
  4. TYPO3com voted on patch set 1 V -1 05/20/19, 12:44 Completed build in 06m 38s on Mon, 20 May, 02:44 PM Test Summary: 7331 of 46775 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33936

  5. Helmut Hummel commented on patch set 1 05/20/19, 12:54

    Feature-87776-LimitRestrictionToTablesInQueryBuilder.rst:24 Reply

    I thought about that. This would mean that we need to extend the interface of the container with this method. This would mean that implementers of containers would need to implement this behavior as well (or inherit it from the abstract), even if they don't need this behavior. Therefore I decided against this approach. With the suggestion here, we have a dedicated class for a dedicated behavior. It is pluggable where needed, and does not interfere with other behavior. I personally find this quite elegant.
  6. TYPO3com voted on patch set 2 V +1 05/20/19, 12:54 Completed build in 12m 29s on Mon, 20 May, 02:54 PM Test Summary: 46513 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33937

  7. Helmut Hummel uploaded patch set 3 05/20/19, 12:57

  8. Mathias Brodala commented on patch set 3 05/20/19, 12:59

    Feature-87776-LimitRestrictionToTablesInQueryBuilder.rst:24 Reply

    Yes, sounds good. :-)
  9. Nicole Hummel voted on patch set 3 CR +1 05/20/19, 13:02

  10. TYPO3com voted on patch set 3 V +1 05/20/19, 13:09 Completed build in 11m 56s on Mon, 20 May, 03:09 PM Test Summary: 46513 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33938

  11. Helmut Hummel commented on patch set 1 05/20/19, 13:24

    Feature-87776-LimitRestrictionToTablesInQueryBuilder.rst:24 Reply

    But of course it is a matter of deciding whether this behavior applies to 90% of the use cases or only 10%. If we decide now (or at some point in the future) that it is useful for 90% of the use cases, we should add a dedicated method for that in the interface for every container.
  12. Helmut Hummel uploaded patch set 4 05/20/19, 14:08

  13. Helmut Hummel commented on patch set 4 05/20/19, 14:09

    Patch set 4 adds (optional) usage examples in the FileSearchQuery class
  14. TYPO3com voted on patch set 4 V -1 05/20/19, 14:24 Completed build in 15m 51s on Mon, 20 May, 04:24 PM Test Summary: 18 of 46852 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-33940

  15. Manuel Selbach wrote 05/21/19, 13:02

    Topic set to persistence
  16. Alexander Schnitzler commented on patch set 4 05/26/19, 11:10

    First of all: Good thing to have this in the core. Applying all restrictions to all tables involved in a query is sometimes a bit annoying. I agree with your implementation but would also opt for adding one or two methods to the QueryRestrictionInterface. Methods like 'enableFor($aliases)' and/or 'disableFor($aliases)'. By adding another method 'getRestrictionByType' on the $queryBuilder, one could have a very nice and short api like: $queryBuilder->getRestrictionByType(HiddenRestriction::class)->disableFor('arbitraryJoinTable'). Just an idea, though...
  17. Manuel Selbach uploaded patch set 5 07/02/19, 16:30

  18. TYPO3com voted on patch set 5 V +1 07/02/19, 16:40 Completed build in 10m 18s on Tue, 2 Jul, 06:40 PM Test Summary: 46848 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34715

  19. Manuel Selbach updated the commit message in patch set 6 07/16/19, 15:39

  20. Manuel Selbach commented on patch set 6 07/16/19, 15:46

    > Patch Set 4: > > First of all: Good thing to have this in the core. Applying all restrictions to all tables involved in a query is sometimes a bit annoying. > > I agree with your implementation but would also opt for adding one or two methods to the QueryRestrictionInterface. Methods like 'enableFor($aliases)' and/or 'disableFor($aliases)'. > > By adding another method 'getRestrictionByType' on the $queryBuilder, one could have a very nice and short api like: $queryBuilder->getRestrictionByType(HiddenRestriction::class)->disableFor('arbitraryJoinTable'). > > Just an idea, though... Thanks for your suggestion. Helmut and I discussed on the topic to add another method in detail a while ago. We decided not to do so, as this will have to be added to the interface and to be implemented at every place even for QueryRestictionContainerInterface as this is inherited from QueryRestritionInterface. This does not mean, it will not be able to add it in the future if the need raises.
  21. TYPO3com voted on patch set 6 V +1 07/16/19, 15:49 Completed build in 09m 38s on Tue, 16 Jul, 05:49 PM Test Summary: 47126 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35104

  22. Manuel Selbach uploaded patch set 7 02/20/20, 09:35

  23. TYPO3com voted on patch set 7 V -1 02/20/20, 10:18 Completed build in 02m 18s on Thu, 20 Feb, 10:18 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-336

  24. Tymoteusz Motylewski uploaded patch set 8 02/24/20, 15:48

  25. TYPO3com voted on patch set 8 V +1 02/24/20, 16:02 Completed build in 14m 02s on Mon, 24 Feb, 04:02 PM Test Summary: 71661 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-635

  26. Tymoteusz Motylewski commented on patch set 8 02/25/20, 07:11

    QueryRestrictionContainerInterface.php:46 Unresolved

    This is a breaking change. We can make it non breaking for v10 by not changing the interface (and introducing the additional param in classes only) and then for v11 do the interface change.
  27. Manuel Selbach uploaded patch set 9 03/30/20, 20:46

  28. TYPO3com voted on patch set 9 V -1 03/30/20, 20:59 Completed build in 13m 04s on Mon, 30 Mar, 08:59 PM Test Summary: 6432 of 73468 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1989

  29. Manuel Selbach uploaded patch set 10 03/30/20, 21:09

  30. TYPO3com voted on patch set 10 V -1 03/30/20, 21:25 Completed build in 16m 00s on Mon, 30 Mar, 09:25 PM Test Summary: 29 of 73237 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1990

  31. TYPO3com commented on patch set 10 03/30/20, 21:44 Completed build in 11m 42s on Mon, 30 Mar, 09:44 PM Test Summary: 25 of 63207 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-1992

  32. TYPO3com commented on patch set 10 03/31/20, 07:25 Completed build in 21m 39s on Tue, 31 Mar, 07:25 AM Test Summary: 24 of 73546 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2006

  33. Manuel Selbach uploaded patch set 11 03/31/20, 08:53

  34. TYPO3com voted on patch set 11 V -1 03/31/20, 09:10 Completed build in 16m 18s on Tue, 31 Mar, 09:10 AM Test Summary: 24 of 73549 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2012

  35. TYPO3com commented on patch set 11 03/31/20, 12:16 Completed build in 19m 23s on Tue, 31 Mar, 12:16 PM Test Summary: 38 of 73549 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2023

  36. TYPO3com voted on patch set 11 V +1 03/31/20, 17:14 Completed build in 5h 35m 53s on Tue, 31 Mar, 05:13 PM Test Summary: 73062 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2023

  37. TYPO3com commented on patch set 11 03/31/20, 17:35 Completed build in 8h 57m 04s on Tue, 31 Mar, 05:35 PM Test Summary: 73062 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2012

  38. Manuel Selbach uploaded patch set 12 03/31/20, 20:02

  39. TYPO3com voted on patch set 12 V -1 03/31/20, 20:23 Completed build in 20m 17s on Tue, 31 Mar, 08:23 PM Test Summary: 72769 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2034

  40. TYPO3com commented on patch set 12 03/31/20, 20:42 Completed build in 18m 11s on Tue, 31 Mar, 08:42 PM Test Summary: 13 of 73254 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2035

  41. TYPO3com commented on patch set 12 03/31/20, 20:53 Completed build in 13m 32s on Tue, 31 Mar, 08:53 PM Test Summary: 6 of 73255 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2036

  42. TYPO3com commented on patch set 12 03/31/20, 21:00 Completed build in 14m 54s on Tue, 31 Mar, 09:00 PM Test Summary: 1 of 73042 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2037

  43. TYPO3com commented on patch set 12 04/01/20, 07:52 Completed build in 11h 22m 00s on Wed, 1 Apr, 07:52 AM Test Summary: 2 of 73564 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2037

  44. TYPO3com voted on patch set 12 V +1 04/01/20, 20:06 Completed build in 11m 18s on Wed, 1 Apr, 08:06 PM Test Summary: 73080 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2068

  45. Benni Mack voted on patch set 12 CR +1 04/13/20, 10:24

  46. Manuel Selbach uploaded patch set 13 04/13/20, 19:44

  47. TYPO3com voted on patch set 13 V -1 04/13/20, 19:45 Completed build in 22s on Mon, 13 Apr, 07:45 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2458

  48. Manuel Selbach uploaded patch set 14 04/13/20, 19:50

  49. TYPO3com voted on patch set 14 V +1 04/13/20, 20:01 Completed build in 10m 52s on Mon, 13 Apr, 08:01 PM Test Summary: 73469 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2459

  50. Benni Mack commented on patch set 14 04/14/20, 14:52

    As this is a conceptual issue since TYPO3 v8 which was possible with TYPO3_DB before, I consider this adding to TYPO3 v10 LTS (if merged by Friday, 17th April 2020), so please review this patch.
  51. Georg Großberger commented on patch set 14 CR +1 04/15/20, 07:53

    AbstractRestrictionContainer.php:86 Unresolved

    Just a micro optimization: "$key = $alias ?? get_class($restriction);"
  52. Manuel Selbach rebased onto patch set 15 04/15/20, 08:31

  1. Manuel Selbach uploaded patch set 16 04/15/20, 08:33

  2. TYPO3com voted on patch set 15 V -1 04/15/20, 08:39 Completed build in 34s on Wed, 15 Apr, 08:39 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2559

  3. TYPO3com voted on patch set 16 V -1 04/15/20, 08:40 Completed build in 50s on Wed, 15 Apr, 08:40 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2560

  4. Manuel Selbach uploaded patch set 17 04/15/20, 08:46

  5. TYPO3com voted on patch set 17 V +1 04/15/20, 08:59 Completed build in 12m 14s on Wed, 15 Apr, 08:59 AM Test Summary: 73553 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2561

  6. Georg Ringer voted on patch set 17 CR +1 04/15/20, 10:17

  7. Frank Nägler voted on patch set 17 CR +1 04/15/20, 19:02

  8. Helmut Hummel commented on patch set 17 04/16/20, 09:03

    I know it was more or less my idea to do it this way. However this has one major downside and that is, that only ONE table based restriction can be added to a query, because restrictions are unique by class name
  9. Markus Klein commented on patch set 17 04/16/20, 18:03

    Feature-87776-LimitRestrictionToTablesInQueryBuilder.rst:78 Unresolved

    I think this is wrong third person. Restriction container that implement ... need to be updated ...
  10. Helmut Hummel commented on patch set 17 04/17/20, 06:59

    Looks mostly good for me. I‘d nevertheless limit this change to the bare minimum before getting it in

    Reply

    Ah solved with optional alias. Nice.

    QueryBuilder.php:1160 Unresolved

    Can you explain what this change is exactly for? (maybe I missed it in the discussion)

    AbstractRestrictionContainer.php:86 Unresolved

    shouldn’t we adapt the interface then as well?

    FileSearchQuery.php:136 Unresolved

    not sure whether it helps to use it here. but it would simplify this change if we could discuss this separately and remove this here.

    FileSearchQuery.php:202 Unresolved

    this in fact is breaking in might reduce flexibility of the search demand
  11. Georg Großberger voted on patch set 17 V +1 CR +1 04/17/20, 11:29

  12. Helmut Hummel commented on patch set 17 CR -2 04/17/20, 12:49

    Working on a more straightforward solution
  13. Helmut Hummel uploaded patch set 18 04/17/20, 14:09

  14. Helmut Hummel voted on patch set 18 CR 0 04/17/20, 14:10

  15. Markus Klein commented on patch set 18 04/17/20, 14:29

    QueryBuilder.php:94

    is this really needed? The container implements the Interface
  16. TYPO3com voted on patch set 18 V +1 04/17/20, 14:37 Completed build in 24m 32s on Fri, 17 Apr, 02:37 PM Test Summary: 73609 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2734

  17. Helmut Hummel commented on patch set 18 04/17/20, 15:28

    QueryBuilder.php:94 Reply

    It is convenience so you can do the following: ``` $queryBuilder->getRestrictions()->limitRestrictionsToTables(['c2']); $queryBuilder->getRestrictions()->addForTables(...); ``` maybe it is better anyway to do: ``` $queryBuilder->getRestrictions()->limitRestrictionsToTables(['c2']); $restrictions = $queryBuilder->getRestrictions(); if ($restrictions intanceof LimitToTablesRestrictionContainer) { $queryBuilder->getRestrictions()->addForTables(...); } ``` hm, yeah. instance of is. better. I'll remove this
  18. Helmut Hummel commented on patch set 18 04/17/20, 15:28

    QueryBuilder.php:94 Reply

    Done
  19. Helmut Hummel uploaded patch set 19 04/17/20, 15:29

  20. Manuel Selbach voted on patch set 19 V +1 CR +1 04/17/20, 15:31

  21. TYPO3com voted on patch set 19 V +1 04/17/20, 15:42 Completed build in 12m 35s on Fri, 17 Apr, 03:42 PM Test Summary: 73608 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2743

  22. Markus Klein voted on patch set 19 CR +1 04/17/20, 15:42

  23. Andreas Kienast voted on patch set 19 CR +1 04/17/20, 18:11

  24. Benni Mack voted on patch set 19 V +2 CR +2 04/17/20, 18:23

  25. Benni Mack merged patch set 20 04/17/20, 18:23