-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Fix error pages in multilang #6608
base: develop-minor
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably could use another unit tests, that really checks the behavior in matching full paths in the router. Any Idea
where to add this unit test?
@distantnative I think it's already covered in the |
@bastianallgeier I can't follow quite. You just replaced the languages with different ones in the existing test, or? But the test is the same as before. Which then would mean that it doesn't test what this PR fixes, cause otherwise it couldn't have passed the checks before this PR. |
I thought that we had some weird edge case when en is the default language. That's why I changed the tests. |
My point is: if those tests passed before this PR, they aren't testing the fix this PR provides. |
As far as I understood @afbora's comment, it worked for some reason with English before, but not with other languages. But I did not double-check if the new test case would have failed before the PR. |
It doesn't fail before this PR either. Will need to look into how a test that really covers the issue needs to look like. |
I can able to test the PR tonight. |
I hate this, cause I cannot find a unit test. Also it's no issue if English is the default language and I don't know why because with the fix in this PR it should also apply to English beforehand. Moving this to 4.5 so we can really be sure that this is the right fix. |
@distantnative The PR fixes the issue. But I'm not sure about that. Something smells not good. I found a clue while trying to write a unit test for this case For ex: Following both codes doesn't give same output (current state, not for this PR). I think loading language ways are different. Set languages from root argument as default$app = new Kirby([
'roots' => [
'index' => __DIR__,
'languages' => __DIR__ . '/site/languages',
'templates' => __DIR__ . '/site/templates'
],
'site' => [
'children' => [
[
'slug' => 'error',
'template' => 'error',
'translations' => [
[
'code' => 'fr',
'content' => [
'title' => 'Erreur'
]
],
[
'code' => 'en',
'content' => [
'title' => 'Error'
]
]
]
]
]
]
]);
echo $app->render('en/not-exist'); Set languages from languages argument (for ex: for unit tests)$app = new Kirby([
'roots' => [
'index' => __DIR__,
'templates' => __DIR__ . '/site/templates'
],
'languages' => [
[
'code' => 'fr',
'name' => 'French',
'default' => true,
'url' => '/'
],
[
'code' => 'en',
'name' => 'English',
'url' => null
],
],
'site' => [
'children' => [
[
'slug' => 'error',
'template' => 'error',
'translations' => [
[
'code' => 'fr',
'content' => [
'title' => 'Erreur'
]
],
[
'code' => 'en',
'content' => [
'title' => 'Error'
]
]
]
]
]
]
]);
echo $app->render('en/not-exist'); |
@distantnative Here you can able to test via 20c1a1b unit test. |
@afbora thank you! I will have a closer look on the weekend. I agree that doesn't smell right at first at least. |
20c1a1b
to
cbdd71e
Compare
Description
Summary of changes
(:all)
. Instead it only matches all that does not start with the URL path prefix of any other page.Reasoning
Additional context
Touching those routing basics etc. is always a delicate matter. I'd be fine with moving this to 5.0, if preferred.
Changelog
Fixes
Error page always rendered in default language for some languages #4834
Ready?
For review team