Closed medienbaecker closed 2 years ago
After two years 😱 I've tracked the issue and I've an clue about the issue.
When call the $page->blueprint()->sections()
code, following line running and broke the translation.
$content = $this->model->content()->toArray();
https://github.com/getkirby/kirby/blob/3.6.3/config/sections/fields.php#L15
As workaround I've fixed the issue with passing current language. I'm not sure about stable solution but this may be give you an idea about solution.
$lang = $this->model->kirby()->language() ?? null;
$content = $this->model->content($lang)->toArray();
@afbora you are a genius :)
Sounds indeed like a good fix. Can we get it in a PR? Ideally we would be able to come up with a unit test that reproduces the buggy behavior before and passes with the fix, but maybe that's hard to do.
Looking at it again, it should be:
$lang = $this->model->kirby()->languageCode();
$content = $this->model->content($lang)->toArray();
✅
Describe the bug
Using
$page->blueprint()->sections()
in e.g. aroute:after
hook breaks all kind of things in the frontend. For example it corrupts the translations and corrupts the page'schildren()
.To Reproduce
Add something like this to the
site/config/config.php
:All I'm doing is putting the sections of the page blueprint in to a
$test
variable. Somehow it breaks all kinds of stuff instead:Expected behavior
Nothing but a variable with the blueprint sections.
Kirby Version
3.3.5
Additional context
I made a plainkit with a simple plugin so you can test the issue: Hook-Bug.zip