From ba5374bdd6569d935a5b5e9dbb60b7461363356b Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 14 Jun 2021 12:49:06 +0000 Subject: [PATCH] Bug 28561: Resolve DBIx's Unable to collapse results-warning Content-Type: text/plain; charset=utf-8 [WARN] DBIx::Class::ResultSet::_construct_results(): Unable to properly collapse has_many results in iterator mode due to order criteria - performed an eager cursor slurp underneath. Consider using ->all() instead at /usr/share/koha/Koha/Objects.pm line 335 DBIx tells: If an "order_by" is already declared, and orders the resultset in a way that makes collapsing as described above impossible (e.g. ORDER BY has_many_rel.column or ORDER BY RANDOM()), DBIC will automatically switch to "eager" mode and slurp the entire resultset before constructing the first object returned by "next". The query in opac-shelves here prefetches biblio, biblioitems and items. May order by itemcallnumber (so that is a has_many column). Note that ordering biblio records (having multiple items) by itemcallnumber is formally impossible. This patch pragmatically removes the order_by clause, but I am open for a better solution ;) Test plan: Pick a list with biblios having multiple items. Show the list in OPAC. Change the sortfield. Check your plack-opac-error.log. --- opac/opac-shelves.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 483876188e..87ef4f0e54 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -275,7 +275,8 @@ if ( $op eq 'view' ) { prefetch => [ { 'biblionumber' => { 'biblioitems' => 'items' } } ], page => $page, rows => $rows, - order_by => { "-$direction" => $order_by }, + # See BZ 28561 Do not trigger Unable to collapse warning by sorting on items fields + $order_by =~ /items/ ? () : ( order_by => { "-$direction" => $order_by } ), } ); -- 2.20.1