From 3347e864ad66061ccd29929cbc1627fe88c6e3fa Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 17 Sep 2020 10:44:01 -0400 Subject: [PATCH] LP#1896070: ensure that deatching course material doesn't delete non-temporary bibs This patch fixes how the temporary_record field is checked; in Perl code, non-NULL Boolean fields in Fieldmapper objects do /not/ evaluate as Perl Boolean values; you have to use $U->is_true() or explictly compare against 't' and 'f'. This patch also tweaks live_t/31-courses.t so that it can be run repeatedly. To test ------- [1] Run live_t/31-courses.t repeatedly; note that it will start failing the second time. [2] Reset the database and apply the patch, then repeat step 1. [3] This time, the test should work when run repeatedly. Signed-off-by: Galen Charlton Signed-off-by: Angela Kilsdonk --- Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm | 2 +- Open-ILS/src/perlmods/live_t/31-courses.t | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm index 304714d8f9..c052ac8a88 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm @@ -226,7 +226,7 @@ sub detach_material { $e->allowed('MANAGE_RESERVES'); my $acmcm = $e->retrieve_asset_course_module_course_materials($acmcm_id) or return $e->die_event; - my $bre_id_to_delete = $acmcm->temporary_record ? $acmcm->record : 0; + my $bre_id_to_delete = $U->is_true($acmcm->temporary_record) ? $acmcm->record : 0; if ($bre_id_to_delete) { # delete any attached located URIs my $located_uri_cn_ids = $e->search_asset_call_number( diff --git a/Open-ILS/src/perlmods/live_t/31-courses.t b/Open-ILS/src/perlmods/live_t/31-courses.t index befa1a075a..8c3c5172c1 100644 --- a/Open-ILS/src/perlmods/live_t/31-courses.t +++ b/Open-ILS/src/perlmods/live_t/31-courses.t @@ -57,16 +57,14 @@ $e->xact_begin; my $bre = Fieldmapper::biblio::record_entry->new; $bre->marc(''); $bre->tcn_source($temp_tcn_source); #Use the tcn_source field, since Cstore rewrites the last_xact_id field -$e->create_biblio_record_entry($bre); +my $temp_bib = $e->create_biblio_record_entry($bre) or die $e->die_event; $e->commit; -my $bib_id = $e->search_biblio_record_entry({tcn_source=>$temp_tcn_source}, {idlist=>1})->[0]; - $e->xact_begin; $acmcm = Fieldmapper::asset::course_module_course_materials->new; $acmcm->course(1); $acmcm->id(9998); -$acmcm->record($bib_id); +$acmcm->record($temp_bib->id); $acmcm->temporary_record(1); # this one is temporary, like brief records created in the course module interface $e->create_asset_course_module_course_materials( $acmcm ); # associated this bib record with a course $e->commit; -- 2.11.0