LP 1319560: Silence template error messages in Apache error log.
authorJason Stephenson <jstephenson@mvlc.org>
Wed, 14 May 2014 19:46:29 +0000 (15:46 -0400)
committerBen Shum <bshum@biblio.org>
Fri, 19 Sep 2014 00:10:34 +0000 (20:10 -0400)
We get a number of messages like the following in our Apache error
logs on a constant basis:

Argument "" isn't numeric in addition (+) at
/openils/var/templates/opac/parts/record/navigation.tt2 line 6.
Argument "" isn't numeric in division (/) at
/openils/var/templates/opac/results.tt2 line 1.
Argument "" isn't numeric in numeric ge (>=) at
/openils/var/templates/opac/parts/record/navigation.tt2 line 38.
Argument "" isn't numeric in numeric gt (>) at
/openils/var/templates/opac/myopac/holds/edit.tt2 line 106.
Argument "" isn't numeric in numeric gt (>) at
/openils/var/templates/opac/myopac/holds.tt2 line 42.
Argument "" isn't numeric in numeric gt (>) at
/openils/var/templates/opac/parts/place_hold.tt2 line 98.
Argument "" isn't numeric in numeric gt (>) at
/openils/var/templates/opac/parts/record/summary.tt2 line 56.
Argument "" isn't numeric in numeric gt (>) at
/openils/var/templates/opac/parts/result/table.tt2 line 87.
Argument "" isn't numeric in numeric lt (<) at
/openils/var/templates/opac/myopac/hold_history.tt2 line 122.
Argument "" isn't numeric in numeric lt (<) at
/openils/var/templates/opac/myopa/result/table.tt2 line 87.
Argument "" isn't numeric in numeric lt (<) at
/openils/var/templates/opac/myopac/hold_history.tt2 line 122.
Argument "" isn't numeric in numeric lt (<) at
/openils/var/templates/opac/myopac/holds.tt2 line 215.

This commit adds some sanity checking to make those messages go
away.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/opac/myopac/hold_history.tt2
Open-ILS/src/templates/opac/myopac/holds.tt2
Open-ILS/src/templates/opac/myopac/holds/edit.tt2
Open-ILS/src/templates/opac/parts/place_hold.tt2
Open-ILS/src/templates/opac/parts/record/navigation.tt2
Open-ILS/src/templates/opac/parts/record/summary.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2
Open-ILS/src/templates/opac/results.tt2

index a28b5b4..8412f42 100644 (file)
@@ -47,7 +47,7 @@
     <div class="clear-both"></div>
 
     <div id='holds_main'>
-        [% IF ctx.holds.size < 1 %]
+        [% IF ctx.holds.size && ctx.holds.size < 1 %]
         <div class="warning_box">
             <big><strong>[% l('No holds found.') %]</strong></big>
         </div>
index 08ebfce..6dbd4a2 100644 (file)
@@ -3,9 +3,9 @@
     PROCESS "opac/parts/hold_status.tt2";
     WRAPPER "opac/parts/myopac/base.tt2";
     myopac_page = "holds";
-    limit = ctx.holds_limit;
-    offset = ctx.holds_offset;
-    count = ctx.holds_ids.size;
+    limit = (ctx.holds_limit.defined) ? ctx.holds_limit : 0;
+    offset = (ctx.holds_offset.defined) ? ctx.holds_offset : 0;
+    count = (ctx.holds_ids.size.defined) ? ctx.holds_ids.size : 0;
 %]
 <h3 class="sr-only">[% l('My Holds') %]</h3>
 <div id='myopac_holds_div'>
@@ -96,7 +96,7 @@
                 </td>
             </tr>
         </table>
-        [% IF ctx.holds.size < 1 %]
+        [% IF ctx.holds.size && ctx.holds.size < 1 %]
         <div class="warning_box">[% l('No holds found.') %]</div>
         [% ELSE %]
         <table id="acct_holds_main_header" title="[% l('Items on Hold') %]"
index e086e8f..6b567a6 100644 (file)
                      
                     <tr><td colspan='4'>
                     [% IF hold.metarecord_filters.formats.size OR
-                        hold.metarecord_filters.langs.size > 1;
+                        (hold.metarecord_filters.langs.size.defined && hold.metarecord_filters.langs.size > 1);
                             PROCESS metarecord_hold_filters_selector 
                                 hold_data=hold; END %]
                     </td></tr>
index 1a497f7..8c70ca5 100644 (file)
@@ -96,7 +96,7 @@
                                 [% l('Advanced Hold Options') %]</a>
                         [% END %]
                         [% IF hdata.metarecord_filters.formats.size OR # should this be size > 1
-                            hdata.metarecord_filters.langs.size > 1;
+                            (hdata.metarecord_filters.langs.size && hdata.metarecord_filters.langs.size > 1);
                             PROCESS metarecord_hold_filters_selector hold_data=hdata;
                         END;
                     END %]
index 29b1106..8b38a7f 100644 (file)
@@ -1,4 +1,4 @@
-[% IF ctx.search_result_index >= 0 %]
+[% IF ctx.search_result_index.defined && ctx.search_result_index >= 0 %]
 <div class="rdetail_header">
     <span class="rdetail_results">
         <a href='[% mkurl(ctx.opac_root _ '/results', {}, stop_parms); %]'>[% l('&#9668; Search Results') %]</a>
index 44746c4..7381acd 100644 (file)
@@ -43,7 +43,7 @@
             [%- search_ou = ctx.search_ou;
                 IF ctx.place_unfillable ||
                     ( attrs.marc_xml.findnodes('//*[local-name()="holdings" and @has_holdable="true"]').size > 0
-                        && (ctx.holds_block.enabled != 'true' || attrs.org_copy_counts.$search_ou.available == 0)
+                        && (ctx.holds_block.enabled != 'true' && !attrs.org_copy_counts.$search_ou.available)
                     )
              %]
             <div class="rdetail_aux_utils place_hold">
index eac0bc5..ef3734b 100644 (file)
@@ -87,7 +87,7 @@
                                                         [% html_text_attr('title', l('Display record details for "[_1]"', attrs.title)) %]>
                                                         [% attrs.title | html %]
                                                      </a>
-                                                     [% IF rec.mr_constituent_count > 1 %]
+                                                     [% IF rec.mr_constituent_count.defined && rec.mr_constituent_count > 1 %]
                                                      <span title="[% l('This group contains [_1] records', rec.mr_constituent_count) %]">
                                                       ([% rec.mr_constituent_count %])
                                                      </span>
index 1bd4d32..a3cb0e1 100644 (file)
@@ -11,7 +11,7 @@
     page = CGI.param('page');
     page = page.match('^\d+$') ? page : 0; # verify page is a sane value
 
-    page_count = ctx.page_size == 0 ? 1 : POSIX.ceil(ctx.hit_count / ctx.page_size);
+    page_count = (!ctx.page_size.defined || !ctx.hit_count.defined || ctx.page_size == 0) ? 1 : POSIX.ceil(ctx.hit_count / ctx.page_size);
 
     PROCESS "opac/parts/misc_util.tt2";
     PROCESS get_library;