From 13adaa938b5621f28ee1e30d200d9cb9787f23a3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 20 Feb 2023 18:35:10 -0500 Subject: [PATCH] LP#2007880: fix open-ils.actor.ou_setting.ancestor_default This patch fixes a regression introduced by bug 2006749 that prevented open-ils.actor.ou_setting.ancestor_default from retrieving the value of a library setting that does not have a view permission associated with it. It also fixes a similar issue with open-ils.actor.org_unit.settings.history.retrieve. To test ------- [1] Use srfsh to retrieve the value of a library setting that does not have a view permission. E.g., request open-ils.actor open-ils.actor.ou_setting.ancestor_default 4, "circ.grace.extend" Note that an error is returned. [2] Apply the patch and repeat step 1. This time, the value of the setting should be returned. [3] Verify that viewing the edit history of a setting in the Library Settings admin page works as expected. Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 24b7fdb43b..59a11f6a30 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -1318,7 +1318,10 @@ sub ou_ancestor_setting { my $coust = $e->retrieve_config_org_unit_setting_type([ $name, {flesh => 1, flesh_fields => {coust => ['view_perm']}} ]); - return undef unless $self->ou_ancestor_setting_perm_check($orgid, $coust->view_perm->code, $e, $auth) + return undef unless defined $coust; + if ($coust->view_perm) { + return undef unless $self->ou_ancestor_setting_perm_check($orgid, $coust->view_perm->code, $e, $auth); + } } my $query = {from => ['actor.org_unit_ancestor_setting', $name, $orgid]}; @@ -1357,9 +1360,10 @@ sub ou_ancestor_setting_log { $name, {flesh => 1, flesh_fields => {coust => ['view_perm']}} ]); + my $perm_code = $coust->view_perm ? $coust->view_perm->code : undef; my $qorg = $self->ou_ancestor_setting_perm_check( $orgid, - $coust->view_perm->code, + $perm_code, $e, $auth ); -- 2.11.0