getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

[3.8.0-rc.1] Reverse relation with UUID via `findBy` not working #4704

Closed doup closed 2 years ago

doup commented 2 years ago

Description

Expected behavior

Your setup

Kirby Version : 3.8.0-rc.1

distantnative commented 2 years ago

@bastianallgeier what do you think - I though relying on casting to string would work and $mode->uuid() could return the UUID instance. But maybe that leads to too many issues in unforeseen places?

bastianallgeier commented 2 years ago

@distantnative I really wonder why the string casting isn't already working in the findBy method. This is pretty weird.

distantnative commented 2 years ago

Because the method isn't casting it:

public function findBy(string $attribute, $value)
{
    foreach ($this->data as $item) {
        if ($this->getAttribute($item, $attribute) == $value) {
            return $item;
        }
    }
    return null;
}

$value being the UUID object.

bastianallgeier commented 2 years ago