Kirby 5 Beta 2: site() causes panel translation issues in plugins

Hi everyone

While testing Kirby 5 (currently beta 2), I encountered an issue where the panel’s site translation for all secondary languages stops working when using site() . This happened, for example, in a panel plugin where I conditionally load blueprints based on user roles:

$blueprintSite = __DIR__ . '/blueprints/editor.yml';

if (site()->userIs('admin')) {
    $blueprintSite = __DIR__ . '/blueprints/admin.yml';
}

use Kirby\Cms\App;

App::plugin('grommasdietz/gd-site-blueprint', [
    'blueprints' => [
        'site' => $blueprintSite,
    ],
]);

I fixed this by switching to kirby() instead of site() :

if ($user = kirby()->user()) {
    if ($user->role() == 'admin') {
        $blueprintSite = __DIR__ . '/blueprints/admin.yml';
    }
}

I noticed the same problem e.g. on this plugin for a virtual home page:

use Kirby\Cms\App;
use Kirby\Cms\Page;
use Kirby\Uuid\Uuid;

load([
    'HomePage' => 'models/HomePage.php',
], __DIR__);

App::plugin('grommasdietz/gd-virtual-homepage', [
	'pageModels' => [
		'home' => HomePage::class
	],
	'pages' => [
		'home' => new Page([
			'slug'     => 'home',
			'template' => 'home',
			'content'  => [
				'title' => site()->title(), // conflicting, works without
				'uuid'  => Uuid::generate(),
			]
		])
	],
]);

The issue seems to be related to the use of site() in a multi-language setup:

  • Instead of rendering translated fields for secondary languages, the content always falls back to the default language.
  • Removing site() resolves the conflict, but it’s not ideal.

I’ve briefly checked the changelog but couldn’t find any reason for this behavior. Could this be a regression? If so, I’m happy to create a GitHub bug report.

It’s a known problem : Incorrect site content in multi-language setup after a plugin uses site()->content() · Issue #2629 · getkirby/kirby · GitHub

Sadly for a long time (so also before v5) but just super hard to solve.

Ah, I see! Recently reworked my boilerplate based on v5 and came across this. As far as I can tell, these two specific scenarios worked fine in v4, so perhaps some of the refactorings in v5 are intensifying the issue?

Thanks for checking into this and providing the reference! Since my custom site blueprint is already functional, I’ll adjust the logic for the virtual homepage to conditionally construct the title. That should resolve it for my case.