TypeError "Kirby\Cms\Url::to(): Argument #1 ($path) must be of type ?string, array given"

Hi there,

I’m pretty new to Kirby and am currently working on setting up my website. Yesterday I updated to Kirby 4.2, which seemed to have worked fine at first. Then I started updating a couple of things in the panel and suddenly the front end page stopped working, the panel still works fine. Switching on debug mode gave me the following error.

I would greatly appreciate if someone could point me to a solution?

Cheers.


TypeError thrown with message “Kirby\Cms\Url::to(): Argument #1 ($path) must be of type ?string, array given, called in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/config/methods.php on line 285”

Stacktrace:
#30 TypeError in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Cms/Url.php:56
#29 Kirby\Cms\Url:to in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/config/methods.php:285
#28 Kirby\Cms\Core:{closure} in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Content/Field.php:78
#27 Kirby\Content\Field:__call in /mnt/web309/a1/49/512426249/htdocs/XXX/site/plugins/zero-one/snippets/header/navbar.php:79
#26 include in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:425
#25 Kirby\Filesystem\F:loadIsolated in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:364
#24 Kirby\Filesystem\F:Kirby\Filesystem{closure} in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:372
#23 Kirby\Filesystem\F:load in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Toolkit/Tpl.php:36
#22 Kirby\Toolkit\Tpl:load in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Template/Snippet.php:172
#21 Kirby\Template\Snippet:factory in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/config/components.php:301
#20 Kirby\Cms\Core:{closure} in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Cms/App.php:1546
#19 Kirby\Cms\App:snippet in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/config/helpers.php:531
#18 snippet in /mnt/web309/a1/49/512426249/htdocs/XXX/site/plugins/zero-one/snippets/header.php:93
#17 include in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:425
#16 Kirby\Filesystem\F:loadIsolated in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:364
#15 Kirby\Filesystem\F:Kirby\Filesystem{closure} in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:372
#14 Kirby\Filesystem\F:load in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Toolkit/Tpl.php:36
#13 Kirby\Toolkit\Tpl:load in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Template/Snippet.php:172
#12 Kirby\Template\Snippet:factory in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/config/components.php:301
#11 Kirby\Cms\Core:{closure} in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Cms/App.php:1546
#10 Kirby\Cms\App:snippet in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/config/helpers.php:531
#9 snippet in /mnt/web309/a1/49/512426249/htdocs/XXX/site/plugins/zero-one/templates/home.php:1
#8 include in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:425
#7 Kirby\Filesystem\F:loadIsolated in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:364
#6 Kirby\Filesystem\F:Kirby\Filesystem{closure} in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Filesystem/F.php:372
#5 Kirby\Filesystem\F:load in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Toolkit/Tpl.php:36
#4 Kirby\Toolkit\Tpl:load in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Template/Template.php:163
#3 Kirby\Template\Template:render in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Cms/Page.php:1017
#2 Kirby\Cms\Page:render in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Cms/App.php:775
#1 Kirby\Cms\App:io in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/src/Cms/App.php:1189
#0 Kirby\Cms\App:render in /mnt/web309/a1/49/512426249/htdocs/XXX/index.php:17

…in fact, retracing my steps I just found out that what is causing the error is a button that I added the following way:

Without that button the page loads again as it should. I tried also to switch the button link to URL and put in a valid string. Same problem. That button just doesn’t seem to work.

TypeError thrown with message “Kirby\Cms\Url::to(): Argument #1 ($path) must be of type ?string, array given, called in /mnt/web309/a1/49/512426249/htdocs/XXX/kirby/config/methods.php on line 285

The message says that the method expects a path as a string, but instead it is passed an array.

Can you give us any additional information?
How was this button integrated into the panel?
Have you installed any plugins?
Have you made additional entries in config.php? For example, in connection with plugins?

Hi @JPS, I answered you on email.

Johannes is using a Zero One theme, so I will help him over the email. Because I cannot reproduce the issue, my 99,9% guess is that he didn’t update properly. I will solve that with Johannes.

1 Like

Thanks a lot for your message @mrfreedom and for the great support! Very much appreciated. With your indications via email I found out my mistake. The problem clearly was a user error. Even though I carefully followed your update instructions and managed to update the website locally, I uploaded only the new files to the server without deleting the old ones that needed to be deleted. Everything is working properly now.

Have a great day.

1 Like

Hi @JPS, good to hear you solved it!

Yes, the Kirby Link Field plugin if not removed cause that error.