Upgrade to 2.5.6/2.5.7: Cannot declare class Asset, because the name is already in use


Hm. in my test with a 2.5.7 langkit it worked with $site, no whoopsydoopsy


wellllllll theres definitely a whoopsydoopsy over here :slight_smile:

fails at the first fence…

    'title' => function($page) {
        return $page->isHomePage()
                ? $site->seotitle()
                : $page->seotitle().' | '. $site->seotitle();


Ok, you are right, I didn’t put that meta tag code into my head tag. Then I don’t know what to do.


I’ll test the Meta Tags plugin with the langkit now to see if I get the same error and change the plugin as needed.


Awesome, thanks @pedroborges also thanks @texnixe for taking the time to isolate it.


Hm, on the other hand, with the plugin installed and the code in the head, site() doesn’t throw an error anymore? Weird.


In my tests when the site() function is called inside a callback it works, but it throws the same error if used directly on an array item, like so:

c::set('meta-tags.default', [
  'title' => site()->title() // Fatal error: Cannot declare class Asset, because the name is already in use in /Users/pedro/Code/langkit/kirby/branches/multilang.php on line 6


Yes, if you wrap everything in a callback, it seems to work.


When I dump site() the multilang property is set to false. Shouldn’t it be true since I’m testing on the langkit?

object(Site)#21 (11) { ["title"]=> string(18) "Kirby Sprachen-Kit" ["url"]=> string(18) "http://langkit.dev" ["page"]=> string(4) "home" ["content"]=> object(Content)#22 (2) { ["root"]=> string(45) "/Users/pedro/Code/langkit/content/site.de.txt" ["fields"]=> array(3) { ["title"]=> string(18) "Kirby Sprachen-Kit" ["description"]=> string(30) "Dies ist Kirby's Sprachen-Kit." ["copyright"]=> string(71) "© 2009–(date: Year) (link: http://getkirby.com text: Das Kirby-Team)" } } ["children"]=> object(Children)#26 (6) { [0]=> string(8) "projects" [1]=> string(4) "blog" [2]=> string(5) "about" [3]=> string(7) "contact" [4]=> string(5) "error" [5]=> string(4) "home" } ["files"]=> object(Files)#33 (0) { } ["multilang"]=> bool(false) ["locale"]=> string(10) "en_US.UTF8" ["user"]=> bool(false) ["users"]=> object(Users)#34 (0) { } ["roles"]=> object(Roles)#35 (3) { [0]=> string(6) "editor" [1]=> string(5) "admin" [2]=> string(6) "nobody" } }

EDIT: That happens when I dump site() from the config.php file. If I dump on a template it shows multilang as true.


I just reverted the langkit to commit ed41777 (v. 2.5.5) and using site() directly on the config file worked as expected.


I have tracked down the issue and it was introduced on commit #9cc028c. When commenting out line 157 the error goes away.


Yes, it‘s exactly that: If you call any Kirby object like kirby() or site() before the config is fully loaded (meaning: directly from config, not from a callback, which is fine as they are executed later), this issue appears.

Put as I pointed out in the GitHub issue that was linked to by Sonja above, this is a „won’t fix“ as there is no way to get this right. As you said, the multilang stuff can only be initialized after the config is fully loaded, so we don‘t support any direct access to the Kirby objects before that.

But as you already found out, callbacks are fully supported and therefore the way to go.


Thanks for the detailed reply @lukasbestle. In order to help avoid this issue I just release a new version of the Meta Tags plugin. You can find more about this release at Meta Tags Plugin.


Nice! Thanks @pedroborges!