Error Object of class Kirby\Cms\Page could not be converted to int which using Search

I am trying to develop the search module using instructions in link but i am getting this above error in file \kirby\src\Toolkit\Collection.php.


search.php controller the code is

<?php

use Kirby\Http\Remote;

return function ($site) {

    $query   = get('q');

    $results = $site->search($query, 'title|text');

    $results = $results->paginate(20);

  

    return [

      'query'      => $query,

      'results'    => $results,

      'pagination' => $results->pagination()

    ];

}?>

Could you please post the stack trace?

Your code looks like an old Kirby version. Which Kirby version are you using? This was an issue in the old version.

Hm, the only thing on line 25 of the controller is the closing tag, which should be removed, because PHP files should not end with a closing tag.

The rest of the code looks alright to me.

3.1.2

Yes, this is an old issue. Please upgrade to last Kirby version as 3.4.5 to stable work.

Do not forget to take a backup before upgrading. There have been some breaking changes between versions :warning:

Thanks a lot to you and pixelijn for your glorious and instant support.

This is for version 3.1.2 fix
Goto line nos: 917 in \kirby\src\Toolkit\Collection.php and replace

array_multisort($params);

WITH

array_multisort(...$params);

This should fix the issue without any upgrade required.

While this might fix it, we cannot really recommend this. You should really always update to the latest version to make sure you get all bug–and even more important–security fixes.