Custom Filter function does not work in 3.5.3

i have some custom filters directly inside my controller that used to work up to Kirby 3.4 but since i made the move to 3.5.3 they yield empty results. did anything change in the syntax (of PHP)?

Excerpt from controller/calendar.php

 function filterPast($child) {
      return ( (strtotime($child->enddate()) < strtotime(date("Y-m-d 23:59:59")) + (1 * 22 * 60 * 60)));
  };

$pastexhibitions = $exhibitions->filter('filterPast');

If i copy the function directly inside the filter everything works as before:

$pastexhibitions = $exhibitions->filter(function ($child) {
      return ( (strtotime($child->enddate()) < strtotime(date("Y-m-d 23:59:59")) + (1 * 22 * 60 * 60)));
});

Yes there was an update in 3.5.2

To be honest, I would prefer to stick with the change we made and the second notation. The reason for the change is an accidental php method call if the field is named in a certain way. We can avoid this more easily with our change.

Ok, that’s understandable and totally fine for me! What would be the preferred way of avoiding global functions? Only thing i found was via extensions: Collection filters | Kirby?

You can store your function in a variable and then pass it to the filter() method:

$filterPast = function ($child) {
    return ( (strtotime($child->enddate()) < strtotime(date("Y-m-d 23:59:59")) + (1 * 22 * 60 * 60)));
};

$pastexhibitions = $exhibitions->filter($filterPast);

thanks! much better and familiar syntax! i am lagging some very basic php knowledge i just realised :wink: