[5.x]: The .language()
entry query parameter doesn't account for site tokens
#15767
Labels
.language()
entry query parameter doesn't account for site tokens
#15767
What happened?
Description
If the
.language()
entry query param is passed a language code that no sites use, Craft will throw an InvalidArgumentException "Invalid language" – which is generally fine.However, this can also happen when previewing content in disabled sites, if there are no enabled sites using the language code passed to
.language()
; presumably because the.language()
param logic does not account for languages from disabled sites even if there is asiteToken
in the URL.Effectively, this makes it impossible to preview content in disabled sites in cases where there is an entry query using the
.language()
query param with a language code only used by the disabled site.Stack trace for the InvalidArgumentException is here: https://pastebin.com/t1HtpLaZ
Steps to reproduce
sv
), and disable that site.Expected behavior
It should be possible to preview content in disabled sites, even if the
.language()
param is used with the language that the disabled site uses (and no other enabled sites use)Actual behavior
Craft throws an InvalidArgumentException if the
.language()
param is passed a language code that no enabled sites use, even if there is a validsiteToken
in the request URL.Craft CMS version
5.4.4
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: