Pluck() deprecated in PHP 8.1+ / Kirby 3.8+

Hello,

My webserver provider has upgraded to PHP 8. On this occation I upgraded Kirby CMS to 3.9 which supports PHP version 8.2.

I am using the Grid-Layout ‘masonry.js’ from DeSandro to filter specific tags. In my gallery.php file (/controllers) I have the following setup:

<?php

return function($site, $pages, $page) {

  // fetch the basic set of pages
  $projects = $page->children()->visible();

  // add the tag filter
  if($tag = param('tag')) { // old because of php upgrade from 7 to 8
    $projects = $projects->filterBy('tags', $tag, ',');
  }

  // fetch all tags
  $tags = $projects->pluck('tags', ',', false);

  return compact('projects', 'tags', 'tag');
};

I have noticed that the pluck()-method is deprecated in PHP 8.1+ and therefore my grid is broken. Does anybody know how to fix it?
Is there an alternative method to pluck() ?
Or should I use another grid layout (javascript).

Thanks for any ideas in advance.

P. S. This fix would be also relevant to the cookbook. filtering-with-tags

The pluck method is a Kirby collection method and is not deprecated.

What is no longer valid code (because from Kirby 2) is this line:

Which should be listed() instead of visible()

Awesome!

Thanks for clearing that up.