$pages->find() not working as expected?

Hi,

I recently updated a site to Kirby 3 and found something strange: $pages->find() is not working as it did before. I used to get a result for $site->grandChildren()->find('page-title'), which is not working anymore. However, if I use $site->grandChildren()->findBy('uid', 'page-title'), using the identical page title, I get the page I want. To my understanding, those two lines should return the same page, right? At least that’s what they used to do.
Is this expected, or user error, or a bug?

Thanks,
Till

From which Kirby version did you update? find() expects a page id as parameter, not the title.

I updated from 3.4 to 3.6.1.1

I am giving a uid as parameter to find(), I use the same parameter that I use for findBy('uid'), which works fine.

Another thing I just noticed: the code that uses find() works fine in the two secondary languages on my site (German and French), but not in the first language (English). The UID of the page that is to be found is identical in all three languages. findBy('uid') works across all languages, find() only returns a result in German and French.

Hm, yes, I can reproduce the issue. It works if you pass the id, e.g. in a Starterkit:

<?= $site->grandChildren()->find('notes/exploring-the-universe')->title() ?>

While it works with the slug in case of non-default languages.

So am I correct in my understanding: the correct behavior would be that $pages->find() should not work with uids and only works with the full ids? Basically I was using it wrong before, which used to work and now stopped working in the default language but somehow still works in non-default languages?

If this is correct, then it was a bug before and now is still (but somehow less of) a bug. Or maybe it was a feature before (being able to use $pages->find() with a uid/slug) which now is not working correctly anymore?

Anyhow, I updated my code to use $site->grandChildren->findBy('uid', page-slug), so there’s a solution :slightly_smiling_face:

Hm, might actually be a bug, given that it works as expected in a non-multilang installation.

Thanks for you help!
How does it work – do you report the bug, should I do something?

1 Like