[DOCU-2830] Add more information on the virtual mappings' evaluation order Created: 07/Sep/23  Updated: 11/Sep/23  Resolved: 11/Sep/23

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Nils Andre Assignee: Alex Mansell
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File vurifilter-debug.patch    
Issue Links:
Relates
relates to MAGNOLIA-9084 Provide debug logs for Virtual URI ma... Closed
Documentation page URL: https://docs.magnolia-cms.com/product-docs/6.2/Administration/URI-mapping/Virtual-URI-mapping.html
Reporter Name: Nils Andre
Email: nils.andre@jobrad.org

 Description   

We had troubles in debugging the virtual URI mapping application/evaluation order (for a 
MultiSiteRegexpVirtualUriMapping)
By chance, we found out that the number of matching Regular Expression Groups might be involved in the weighing of each mapping (which was confirmed by Jürgen Brommer and a technician), and that the mapping with the maximum weight is to be applied. However, we had troubles in understanding and debugging these issues, since we could not find any logger who would report on that (with ALL log level). 

We would very much appreciate if you update the docs on this.

We found a groovy script for debugging, but unfortunately, this did not work with our MultiSite-Configuration:

https://gist.github.com/mkgl/c800a005b7ee960351fae1563d7a148f

Heaps of thanks and best wishes from the JobRad CMS/Platform team.



 Comments   
Comment by Mikaël Geljić [ 08/Sep/23 ]

Hi nandre,

Virtual URI mappings' weight depends on two main mapping classes implementations:

  • DefaultVirtualUriMapping, HostBasedVirtualUriMapping and MultiSiteRootVirtualUriMapping's weight is the pattern length;
  • RegexpVirtualUriMapping and host-based, multisite variations' weight is based on the count of matching groups—as per Matcher javadoc, + 1 (I suppose in case there's no capturing group).

Do you by any chance have a combination of "default" and regexp URI mappings?

Here's an example debug output to illustrate, from a modifed VirtualUriFilter with debug logs (attaching the patch, most likely I'll file a PR too):

DEBUG info.magnolia.virtualuri.VirtualUriFilter         : Evaluating Virtual URI mappings for URI /news/tech/2023/august/news.html
DEBUG info.magnolia.virtualuri.VirtualUriFilter         : └── DefaultVirtualUriMapping[/news/* --> defaultWon]: weight 6
DEBUG info.magnolia.virtualuri.VirtualUriFilter         : └── RegexpVirtualUriMapping[/news/(tech/)?([0-9]+)/([a-zA-Z]+)/(.*)\.html --> regexWon/tech/$4/$2/$3]: weight 5
DEBUG info.magnolia.virtualuri.VirtualUriFilter         :    Best match: DefaultVirtualUriMapping[/news/* --> defaultWon] => defaultWon

Hope this helps!
-Mika

Generated at Mon Feb 12 01:30:40 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.