From 25bd5a725f586a84107034c5ba0f3906a7d33b15 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 20 Jun 2018 09:22:38 -0400 Subject: [PATCH] LP#1773832: Empty deleted records can be surfaced in search results There are cases where we avoid checking the deleted flag of bibs as an optimization that avoids a JOIN in the search query. However, for some shapes of real-world data, particularly in upgraded instances, deleted records can slip through. This commit adds an explicit check for the flag to all search queries. Signed-off-by: Mike Rylander Signed-off-by: Daniel Pearl Signed-off-by: Jason Stephenson --- .../lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index 981bff9918..6141d664ed 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -883,8 +883,8 @@ sub toSQL { $bre_join = 'INNER JOIN biblio.record_entry bre ON m.source = bre.id AND bre.deleted'; # The above suffices for filters too when the #deleted modifier # is in use. - } elsif ($$flat_plan{uses_bre} or !$self->find_modifier('staff')) { - $bre_join = 'INNER JOIN biblio.record_entry bre ON m.source = bre.id'; + } else { + $bre_join = 'INNER JOIN biblio.record_entry bre ON m.source = bre.id AND NOT bre.deleted'; } my $desc = 'ASC'; @@ -1064,7 +1064,7 @@ sub toSQL { "AND (bre.vis_attr_vector IS NULL OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) ))". "))"; # We need bre here, regardless - $bre_join ||= 'INNER JOIN biblio.record_entry bre ON m.source = bre.id'; + $bre_join ||= 'INNER JOIN biblio.record_entry bre ON m.source = bre.id AND NOT bre.deleted'; } my $final_b_attr_test; -- 2.11.0