Review main Abandoned

72861[TASK] Streamline middleware configuration

Stefan Bürk CR 0 V 0 Normal +166 −84 updated 02/04/23, 11:03

Commit message

This patch streamlines frontend and backend middleware
configuration: The order in the config files match
the final order after "resorting" the middleware stack
via DependencyOrderingResolver.

'after' and 'before' refer the direct parent or child
instead of multiple definitions, making the files obvious.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 5

Review log 2939

Show 814 earlier messages
  1. Stefan Bürk uploaded patch set 1 01/04/22, 22:12

  2. Stefan Bürk updated the commit message in patch set 2 01/04/22, 22:13

  3. core-ci voted on patch set 2 V +1 01/04/22, 22:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21622

  4. core-ci voted on patch set 1 V +1 01/04/22, 22:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21621

  5. Stefan Bürk updated the commit message in patch set 3 01/04/22, 22:51

  6. core-ci voted on patch set 3 V +1 01/04/22, 23:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21623

  7. Stefan Bürk updated the commit message in patch set 4 01/05/22, 09:43

  8. core-ci voted on patch set 4 V +1 01/05/22, 09:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21631

  9. Stefan Bürk uploaded patch set 5 01/05/22, 15:47

  10. Stefan Bürk updated the commit message in patch set 6 01/05/22, 15:48

  11. Stefan Bürk marked it work in progress 01/05/22, 16:02

  12. core-ci voted on patch set 6 V +1 01/05/22, 16:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21654

  13. core-ci voted on patch set 5 V +1 01/05/22, 16:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21653

  14. Stefan Bürk marked it ready for review 01/05/22, 16:11

  1. Christian Kuhn updated the commit message in patch set 7 01/05/22, 16:14

  2. core-ci voted on patch set 7 V +1 01/05/22, 16:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21656

  3. Christian Kuhn commented on patch set 7 V +1 CR +1 01/06/22, 14:22

    RequestMiddlewares.php:12

    note: we will probably re-shuffle the redirect handler again in second. this dependency to adminpanel is optional (it's ok if adminpanel is not loaded), but this row currently ensures the redirect-resolver is exactly at the same position as before.
  4. Nikita Hovratov commented on patch set 7 01/06/22, 14:26

    configuration
  5. Benjamin Franzke commented on patch set 7 CR -1 01/06/22, 14:27

    RequestMiddlewares.php:24

    These definitions implicitly define dependencies, you are aware, right? I didn't check this yet, but did you remove typo3/cms-workspaces/preview and typo3/cms-frontend/page-resolver because they are considered implcit due to typo3/cms-frontend/page-argument-validator? If *any* request attribute (or global state :\) is used that is added by typo3/cms-workspaces/preview or typo3/cms-frontend/page-resolver, these dependency definitions must not be removed.
  6. Christian Kuhn commented on patch set 7 CR -1 01/06/22, 14:28

    RequestMiddlewares.php:12 Reply

    actually, forget this comment.
  7. Christian Kuhn commented on patch set 7 01/06/22, 14:41

    Reply

    Done

    RequestMiddlewares.php:12 Reply

    it would be even better if redirects is *before* admin panel.

    RequestMiddlewares.php:24 Reply

    Yes. However, the middleware ordering is not strictly a dependency system, it's just ordering. An instance could still *disable* a middleware noted here, which would break this system. It's task of the middleware implementation here to check required information it depends on and bail out on error. This can't be solved by the ordering system here. We therefor decided to reduce the set of ordering dependencies here. We'll however add an according comment to state these dependencies.
  8. Christian Kuhn uploaded patch set 8 01/06/22, 14:41

  9. Benjamin Franzke voted on patch set 8 CR -2 01/06/22, 14:44

  10. core-ci voted on patch set 8 V +1 01/06/22, 14:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21706

  11. Benjamin Franzke commented on patch set 8 01/06/22, 15:03

    RequestMiddlewares.php:24 Reply

    > It's task of the middleware implementation here to check required information it depends on and bail out on error. Yup, because the dependent middleware may not be loaded at all, but *if* it is loaded, it must be ensured to be loaded before. This is by design, and this change makes our middlewares less reliable when any middleware is moved. This is like Before/After= definitions in systemd services, they define: IF a service is loaded, it needs to be loaded after/before this one: https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before= There are not just hard-dependencies but also weak ordering-definitions in service-management systems, we've got a weak one here. Yes, we don't have hard dependencies in middlewares, still, don't start to hoist ordering information, we wouldn't do that for dependencies, so why would we do so for orderings? Therefore I'd rather reject these changes, sorry. Please explain why this changes (that actually go beyond just reordering) are really needed and what they prepare for. Let's not hoist ordering information, please.
  12. Christian Kuhn commented on patch set 8 01/06/22, 15:41

    RequestMiddlewares.php:24 Reply

    I get your point. You say we shouldn't skip declaring dependencies we do have, even though a middleware with dependencies could still fail if a dependency is disabled. The main thing we wanted to resolve with this patch: When reading the main middleware files top-down, it does not mean that a first middleware is actually executed before another one below - it is kinda often resorted differently. This makes reading these files hard: You have to go to the backend configuration module to see the true ordering of the middlewares. So, if we skip removal of dependencies from the files, I would suggest to strip the patch down to only bring the list of middlewares in the two main files into an order that the ordering service does not shuffle them around again. Stefan did that by adding the 'direct parent' as dependency and removed all other dependencies along the way. I'd love to make the main files better readable by resorting the entries a bit. It would mean that we basically pass the 'before' entries and rely mostly on 'after', partially by adding the direct parent as first after entry. Would you be fine with that? Main goal is to make the main files better readable without having to look at the final sorting displayed in backend configuration module.
  13. Christian Kuhn commented on patch set 8 01/06/22, 15:47

    RequestMiddlewares.php:24 Reply

    Note the formEngine data provider follow a similar approach already in DefaultConfiguration: The first 'after' entry refers to the direct parent (which nails the order), further 'after' entries then declare dependencies. Result: You can read the list top-down in the file and the ordering service can not shuffle the stuff around. This is beneficial for extension devs who want to 'hang in' further entries - they can rely on what they see in the file. This makes everything much easier, especially with rather long lists.
  14. Stefan Bürk commented on patch set 8 01/06/22, 16:20

    RequestMiddlewares.php:24 Reply

    Benjamin, I would suggest to do following: - keep the resorting in the config - readd the removed "after/before", adding comments which are "optional" to be before/after another middle ware and which are "mandantory" to be after/before it. Would that be okay than (generally) ?
  15. Benjamin Franzke commented on patch set 8 CR -1 01/06/22, 17:01

    RequestMiddlewares.php:24 Reply

    Yup, resorting is perfectly fine and I understand the reason. Moving before-declarations to after-declarations is good as well, if applicable. Of course things like adminpanel needs to use `before`, but you know and already kept it there, so that's fine ;) Limiting this patch to these changes would be great, yea. Thanks in advance.
  16. Stefan Bürk uploaded patch set 9 01/07/22, 00:14

  17. Stefan Bürk commented on patch set 9 CR -1 01/07/22, 00:14

    Still on it - just pushed to save state before night break.
  18. core-ci voted on patch set 9 V +1 01/07/22, 00:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21747

  19. Stefan Bürk uploaded patch set 10 01/07/22, 11:57

  20. core-ci voted on patch set 10 V +1 01/07/22, 12:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21761

  21. Christian Kuhn commented on patch set 10 V +1 CR +1 01/13/22, 20:31

    RequestMiddlewares.php:24 Reply

    Done
  22. Benni Mack commented on patch set 10 01/19/22, 09:18

    @bnf fine with you?
  23. Benjamin Franzke commented on patch set 10 CR -1 01/19/22, 09:30

    Reply

    hm sorry, I don't want to offend, but this change introduces too much comment noise for my personal taste. > DIRECT-Parent: core ships it to be sorted after the first one I don't really unterstand the wording in these "DIRECT-Parent" comments. What is this "first one" that is referred here? The first dependency? Also I still have the feeling middlewares are added to make the ordering explicit although there is not really a dependency: For example in typo3/cms-workspaces/preview > 'typo3/cms-frontend/static-route-resolver', // Optional - only for shipped sorting. So this dependency is for some "default" sorting that we don't actually need. It's just there to document the *current* sorting order, but may cause deadlocks if dependencies change or are reordered. I think it will be a nightmare to maintain these explicit "optional – only for shipped sorting" comments. I would actually prefer if we'd introduce PHP 8 Attributes for Middlewares and not try to document the order through our configuration. That's what the "HTTP Middlewares" section in the backend Configuration module is for.

    RequestMiddlewares.php:34 Unresolved

    I think this one needs to stay. ForcedHttpsBackendRedirector uses !$request->getAttribute('normalizedParams')->isHttps() CR-1 because of this one.
  24. Christian Kuhn commented on patch set 10 V 0 CR 0 02/04/23, 11:03

    seems it's very hard to find consensus on this one. let's abandon here for now.
  25. Christian Kuhn abandoned the change 02/04/23, 11:03