Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in the Twig url() function #2524

Closed
newbthenewbd opened this issue May 26, 2019 · 1 comment
Closed

Regression in the Twig url() function #2524

newbthenewbd opened this issue May 26, 2019 · 1 comment

Comments

@newbthenewbd
Copy link
Contributor

In Grav v1.5.10 and older, the Twig expression {{ url('plugins://doesntexist')|default(url('plugins://exists')) }} would have given the same results as the expression {{ url('plugins://exists') }}, provided plugins://exists existed, and plugins://doesntexist didn't. Now, in Grav v1.6.9 (although I suspect the issue to be there since v1.6.0), the expression returns /. The problem is caused by the Twig function url() having ceased to return null when a path is not found, and the offending commit seems to be 66bba37.

This has caused various issues with all the usecases of url() that depend on it returning null when a path is not found, although the issue with url() combined with the default filter seems to be the most evident example - not only has it caused some breakage in my plugin, it was also visible in the Grav documentation at the time of this writing. Due to that, I would like to request that the regression is fixed soon - sadly, I don't currently have the time nor expertise to figure out how exactly that should be done in order to avoid breaking some three hundred other things using that function.

Great thanks to everyone working hard to make Grav a better CMS for us all.

@rhukster
Copy link
Member

Ok after some discussions with @mahagr, we've decided to revert to the previous URL behavior even though this is not really helpful when trying to work out 'why' or 'what' caused the failure in the URL logic. As such I've added a new $fail_gracefully 3rd argument, which when set to true will exhibit the current 1.6 behavior, but is false by default and will return url() the previous behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants