[Koha-bugs] [Bug 6374] New: Use "size" as names/hash keys leads to an unexpected results when using Template::Toolkit (name of a virtual method there)

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu May 19 17:28:46 CEST 2011


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=6374

             Bug #: 6374
           Summary: Use "size" as names/hash keys leads to an unexpected
                    results when using Template::Toolkit (name of a
                    virtual method there)
    Classification: Unclassified
 Change sponsored?: ---
           Product: Koha
           Version: master
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Templates
        AssignedTo: oleonard at myacpl.org
        ReportedBy: januszop at gmail.com
         QAContact: koha-bugs at lists.koha-community.org


In many places the name "size" is used as hash key when the hash is passed to
the template system for display.  So, for example, since "size" is used as a
name of a column of bibioitems table, it appears (or not, depending on if it
was defined or not) in elements of SEARCH_RESULTS (in catalogue/search.pl or
opac-search.pl) and is passed to the template results.tt/opac-results.tt. 
Then, in [opac-]results.tt a test is being done: [% IF ( SEARCH_RESULT.size )
%]

Now: if "size" was defined, everything is OK and the size will be displayed
(e.g. 21 cm), BUT if it was not defined, then a "random" number appears.  

This is because "size" is one of the virtual methods defined in
Template::Toolkit for every data type (cf.
http://search.cpan.org/~abw/Template-Toolkit-2.22/lib/Template/Manual/VMethods.pod).
 So, if "size" was defined by Koha, it will overload the method, but if it was
not, then 1) XXX.size exists anyway, 2) the virtual method size() is called --
and it returns the number of elements in the hash or loop etc., depending on
what is referred. 

The number of suspicious similar spots is ca. 20:  git grep "IF.*\.size" called
in koha-tmpl

The issue does not seem to me to be straightforward to resolve, so I am not
proposing any patch at the time.

Since it seems that in most of the cases it rooted in biblioitems.size column,
maybe it would be the simplest to rename that column to 'format' (and make
appropriate changes in the code)?  Any other ideas?

-- 
Configure bugmail: http://bugs.koha-community.org/bugzilla3/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.


More information about the Koha-bugs mailing list