Skip to content
Snippets Groups Projects
Commit 079cc536 authored by Oliver Hader's avatar Oliver Hader Committed by Oliver Hader
Browse files

[BUGFIX] Adjust processing order of routes during URL generation

Prior to this patch routes were processed in reverse definition order.
Routes defined last came first. Depending on the existence of variable
defaults this behavior produced a couple of unexpected results.

  first:
    routePath: '/route/{a}/{b}'
  second:
    routePath: '/route/{c}'
    defaults:
      c: '0'

The example above, processed in reverse order and having parameters
`a` and `b` given, still resulted in `second` route being used since
the missing parameter `c` was defined by corresponding variable default.

This change adjusts the order of routes depending on given parameters,
completeness of a route (when all parameters are given, even defaults).
Sorting is adjusted based on the following criteria:

* default routes (e.g. `/my-page`) - processed later
* static routes (e.g. `/my-page/list`) - processed later
* all variables are given (complete) - processed earlier
  (e.g. parameters `a` and `b` are given for route `/route/{a}/{b}`)
* all mandatory variables are given (complete) - processed earlier
* less missing variable defaults - processed earlier
* less variable defaults amount - processed earlier

Tests in class `RouteSorterTest` provide more examples & details.

Resolves: #90924
Releases: master, 10.4, 9.5
Change-Id: I26f56e6905472a501ff487295da23b3bc3b5c77e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64877


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarAimeos <aimeos@aimeos.org>
Tested-by: default avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarAimeos <aimeos@aimeos.org>
Reviewed-by: default avatarOliver Hader <oliver.hader@typo3.org>
parent 0f08c166
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment