I have a site using Kirby 4.1.1 with PHP 8.1.27 on a LiteSpeed server.
I get an error when I’m at the root of the panel, and try to save changes, it saves the new data but I get an error message pop up. It seems to have something to do with language being enabled.
The error message
Kirby\Content\ContentStorage::contentFile(): Argument #2 ($lang) must be of type string, null given, called in /.../.../.../public_html/kirby/src/Cms/ModelWithContent.php on line 185
The strange thing is that the staging site with the same content, same host, LiteSpeed server and PHP version but on a different domain does not have this problem.
The site also works without errors locally with MAMP Pro.
Does anyone here have any idea what could be causing the error? Or having advice on where I can start troubleshooting…
Hi Sonja, as far as I know, I don’t. I haven’t done any panel code. It must be Kirby calling that function when I save.
I have downloaded all the code and content from the production site using rsync and uploaded it to the staging site. But no error occurs on staging. So weird.
Well, the method ModelWithContent::contentfile (which then calls $this->storage()->contentFile) is deprecated, so definitely no longer used by Kirby anywhere.
Could you please check your code if you filter by contentfile somewhere?
Unfortunately, the site is locked to the autoid plugin. Maybe that’s what’s causing the problem. It’s just strange that I can’t reproduce the problem locally.
Found this in the AutoID plugin. It feels like that could be what is creating the error.
The goal is to phase out the plugin but there is a lot of content that depends on it so it is not that simple.
private function itemFromSite($object): array
{
return [
'page' => '$',
'diruri' => '$',
'modified' => filemtime($object->contentFile()), // just site not ALL
'kind' => AutoIDItem::KIND_PAGE,
'template' => 'site',
];
}