LP1272316 - Followup to make ou_ancestor_setting() even faster
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 24 Jan 2014 17:33:13 +0000 (12:33 -0500)
committerBen Shum <bshum@biblio.org>
Fri, 28 Feb 2014 17:34:39 +0000 (12:34 -0500)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm

index ab674ef..d6f616e 100644 (file)
@@ -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]};