Bug 20799: (QA follow-up) Move syspref check
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 22 Jul 2020 09:09:29 +0000 (10:09 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 24 Jul 2020 12:11:53 +0000 (14:11 +0200)
This patch moves the syspref check into the controller to save a DB
query if the module is not enabled.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

JD - amended patch: removing trailing parenthesis in the IF statement

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt

index 5e10954..d01de15 100755 (executable)
@@ -540,7 +540,10 @@ my $holds = $biblio->holds;
 $template->param( holdcount => $holds->count );
 
 # Check if there are any ILL requests connected to the biblio
-my $illrequests = Koha::Illrequests->search({ biblio_id => $biblionumber });
+my $illrequests =
+    C4::Context->preference('ILLModule')
+  ? Koha::Illrequests->search( { biblio_id => $biblionumber } )
+  : [];
 $template->param( illrequests => $illrequests );
 
 my $StaffDetailItemSelection = C4::Context->preference('StaffDetailItemSelection');
index 96a8ebc..dbb1ca1 100644 (file)
             </span>
         [% END %]
 
-        [% IF ( Koha.Preference( 'ILLModule' ) && illrequests.count ) %]
+        [% IF illrequests.count %]
             <span class="results_summary">
                 <span class="label">ILL requests:</span>
                 [% IF CAN_user_ill %]