[Bug 28561] New: Order_by triggers a DBIx warning Unable to properly collapse has_many results
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Bug ID: 28561 Summary: Order_by triggers a DBIx warning Unable to properly collapse has_many results Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: m.de.rooy@rijksmuseum.nl QA Contact: testopia@bugs.koha-community.org Make a list, few biblios with multiple items. Check the plack-opac-error.log [2021/06/14 11:51:45] [WARN] Use of uninitialized value $direction in string ne at /usr/share/koha/opac/opac-shelves.pl line 265. [2021/06/14 11:51:45] [WARN] Use of uninitialized value $direction in string ne at /usr/share/koha/opac/opac-shelves.pl line 265. [2021/06/14 11:51:45] [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 Koha/Objects Line 335 says: my $result = $self->_resultset()->next(); The warning has to do with the sorting criteria. Disabling the order_by clause removes the warning. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |m.de.rooy@rijksmuseum.nl |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #1 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- This query in opac/opac-shelves.pl contains the crux: my $contents = $shelf->get_contents->search( {}, { prefetch => [ { 'biblionumber' => { 'biblioitems' => 'items' } } ], page => $page, rows => $rows, order_by => { "-$direction" => $order_by }, } ); -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #2 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- The code in opac-shelves is far from optimal. The prefetch in the query selects biblio, biblioitems and items. But in the loop starting at L308 we are calling GetBiblioData, GetMarcBiblio, Biblios->find, GetItemsLocationInfo, $biblio->items. Horrible ;) DBIx says about prefetching and collapse the following: 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". So if we are 'sorting' by itemcallnumber in an "has many" table, we will trigger the warning. In that case we can remove the sort anyway. This is a bit lazy 'solution' but this report was not about refactoring opac-shelves. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #3 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 121912 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=121912&action=edit Bug 28561: Resolve DBIx's Unable to collapse results-warning [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. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #4 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 121913 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=121913&action=edit Bug 28561: Fix noisy warning about $direction too Use of uninitialized value $direction in string ne at /usr/share/koha/opac/opac-shelves.pl line 265. Bonus: Use of uninitialized value $sortfield in string eq at /usr/share/koha/opac/opac-shelves.pl line 264. Test plan: While testing patch 1, check the logs for these warnings with and without this patch. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #5 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- NOTE: Although this patch significantly reduces the number of warnings on the collapse. I still had some when I sorted on title too. It seems that it does not occur on the other fields as author etc. Not sure why. Caching? [2021/06/14 13:06:59] [WARN] L272title-title at /usr/share/koha/opac/opac-shelves.pl line 272. [2021/06/14 13:06:59] [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 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |In Discussion --- Comment #6 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Still hesitant if we should proceed like that.. What do you think? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart+koha@gmail. | |com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #7 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 122119 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122119&action=edit [ALTERNATIVE PATCH] Bug 28561: Remove DBIC warning in opac-shelves -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #8 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- We don't actually need to prefetch as we are only using the biblionumber. Using join and distinct seems to remove the warning and produce the same results. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #9 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 122215 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122215&action=edit Bug 28561: Remove DBIC warning in opac-shelves Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #121912|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #122119|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #10 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Jonathan Druart from comment #8)
We don't actually need to prefetch as we are only using the biblionumber. Using join and distinct seems to remove the warning and produce the same results.
So simple.. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #121913|0 |1 is obsolete| | --- Comment #11 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 122743 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122743&action=edit Bug 28561: Fix noisy warning about $direction too Use of uninitialized value $direction in string ne at /usr/share/koha/opac/opac-shelves.pl line 265. Bonus: Use of uninitialized value $sortfield in string eq at /usr/share/koha/opac/opac-shelves.pl line 264. Test plan: While testing patch 1, check the logs for these warnings with and without this patch. Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #122215|0 |1 is obsolete| | --- Comment #12 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 122744 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122744&action=edit Bug 28561: Remove DBIC warning in opac-shelves Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com QA Contact|testopia@bugs.koha-communit |nick@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to master Version(s)| |21.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 --- Comment #13 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Pushed to master for 21.11, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |Pushed to stable CC| |kyle@bywatersolutions.com Version(s)|21.11.00 |21.11.00,21.05.02 released in| | --- Comment #14 from Kyle M Hall <kyle@bywatersolutions.com> --- Pushed to 21.05.x for 21.05.02 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to stable |Pushed to oldstable CC| |fridolin.somers@biblibre.co | |m Version(s)|21.11.00,21.05.02 |21.11.00,21.05.02,20.11.09 released in| | --- Comment #15 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to 20.11.x for 20.11.09 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to oldstable |RESOLVED Resolution|--- |FIXED CC| |victor@tuxayo.net --- Comment #16 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28561 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |36914 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36914 [Bug 36914] DBIx::Class warning from shelves.pl -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org