From 4cb16a9f07180d4ef99c960834994e32b82d5881 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Fri, 24 Jan 2014 12:33:13 -0500 Subject: [PATCH] LP1272316 - Followup to make ou_ancestor_setting() even faster Signed-off-by: Lebbeous Fogle-Weekley Signed-off-by: Mike Rylander Signed-off-by: Chris Sharp Signed-off-by: Ben Shum --- .../lib/OpenILS/Application/AppUtils.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index ab674effb0..d6f616e136 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -1286,15 +1286,17 @@ sub ou_ancestor_setting { $e = $e || OpenILS::Utils::CStoreEditor->new( (defined $auth) ? (authtoken => $auth) : () ); - my $coust = $e->retrieve_config_org_unit_setting_type([ - $name, {flesh => 1, flesh_fields => {coust => ['view_perm']}} - ]); - if ($auth && $coust && $coust->view_perm) { - # And you can't have permission if you don't have a valid session. - return undef if not $e->checkauth; - # And now that we know you MIGHT have permission, we check it. - return undef if not $e->allowed($coust->view_perm->code, $orgid); + if ($auth) { + my $coust = $e->retrieve_config_org_unit_setting_type([ + $name, {flesh => 1, flesh_fields => {coust => ['view_perm']}} + ]); + if ($coust && $coust->view_perm) { + # And you can't have permission if you don't have a valid session. + return undef if not $e->checkauth; + # And now that we know you MIGHT have permission, we check it. + return undef if not $e->allowed($coust->view_perm->code, $orgid); + } } my $query = {from => ['actor.org_unit_ancestor_setting', $name, $orgid]}; -- 2.43.2