Open michalkleiner opened 5 years ago
It seems though providing the empty rule is not working in SS4. It used to in SS3.
Is there a better way to remove a route defined by a 3rd party module?
For now, using a workaround through an extension to Director.
The underlying question still stands — should Director and SiteTree skip patterns with empty rules?
I'm a big fan of using null
as "not a value", but ''
as "value, explicitly empty". Shall we filter out rules with isset?
With isset
check, how would you remove a yaml config (3rd party defined route) via yaml config (custom module to remove the config)? Or how do you specify null
to override it via yaml?
@chillu or @tractorcow can you please give me some direction so I can PR this? Thanks
So to be clear, this is about the values (usually controller names) rather than the keys (path matching rules). I think null
communicates the intent better, and that's a thing in YAML as well: https://yaml.org/type/null.html. I'm not sure if our merging logic does the right thing there (takes the null value if it has higher priority), but that'd be my preference. So this wouldn't remove the config entry, it just overrides it with a null value. Which I think is easier to debug anyway.
Otherwise, I can't see how an empty string as the controller name would be used for anything but "disable this rule", so fine with that as well.
When trying to remove CWP search recipe imposed 'search' route, using an empty string works, however, any defined route (with or without a functioning route) gets rejected as a possible SiteTree URL segment.
CWP route definition: https://github.com/silverstripe/cwp-search/blob/master/_config/routes.yml
SiteTree URL segment exclusions: https://github.com/silverstripe/silverstripe-cms/blob/4/code/Model/SiteTree.php#L3097
Should routes with empty rules be allowed as URL segment candidates? If so, I can PR that.