UUID output unintentionally in lowercase when grouping by pages field?

Page UUIDs are case sensitive, yes? I’m currently grouping a pages collection by a pages field:

$zeiten = $page->children()->template('trainingszeit')->listed()->groupBy('gruppe');

if I then retrieve the pages field in a loop in the template I get the UUID in lowercase, so I’m not able to fetch the linked page:

<?php foreach($zeiten as $gruppe => $gruppenItems): ?>
   <?= $gruppe ?>
<?php endforeach ?>

This outputs - page://nagkjs5pduozqrof in lowercase, whereas the UUID is actually page://NAGkjs5PDuOzqrof. I checked the case in both the source page content and the page content in which it was linked. For some reason this all worked fine yesterday and is broken today.

var_dump($zeiten) looks like this:

object(Kirby\Cms\Collection)#452 (3) { [0]=> string(25) "- page://nagkjs5pduozqrof" [1]=> string(25) "- page://gpcgpbofflnhe1d6" [2]=> string(25) "- page://1fvcqs75jlh8xjab" }

Is this a bug or something else at play?

Also I’m using page(str_replace('- ', '', $gruppe)) to get rid of the yaml-list-hyphen. There sure is a better way to do this in Kirby, but I have tried all methods I was able to find and only this worked.

Thanks for help and hints!

You should be able to fix this issue by passing false as a second parameter to the group method.

However, I don’t think your approach is correct like this, as you are dealing with a yaml list (even with only one entry in your case).

If I were you, I wouldn’t use this hack with string replacement, but instead use group with a callback,

@texnixe many thanks Sonja! As @nilshoerrmann pointed out, the lowercase uuid was created because it was used as in index during grouping.

However I fixed this by using pluck() to get the values for grouping and doing a second loop with a filter. So I avoided using either group() or groupby() ;).

This works as well:


$zeiten = $page->children()->template('trainingszeit')->listed()->group(function($item) {
     return $item->gruppe()->toPage();
});