[Koha-bugs] [Bug 5786] Move AllowOnShelfHolds system preference to the Circulation Matrix

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Sep 21 18:10:51 CEST 2012


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

Paul Poulain <paul.poulain at biblibre.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|Signed Off                  |Failed QA

--- Comment #61 from Paul Poulain <paul.poulain at biblibre.com> ---
QA comment:

* I've found some glitches with koha-qa.pl, i've fixed them. They were very
minor.
* After an intensive testing, I've found a tricky problem, that occurs only
under some specific cases. Let me explain:
 Issuing rules are : default library (branchcode='*'), you say 'ShelfHolds =
no'
 for a given library, a given itemtype, and any categorycode, you say 'yes' =>
only 'BOOKS' from 'Library A' can be reserved while on shelf.

In this case, you will get a wrong result from your query:
SELECT opacitemholds,categorycode,itemtype,branchcode FROM issuingrules WHERE
          (issuingrules.categorycode = ? OR issuingrules.categorycode = '*')
        AND
          (issuingrules.itemtype = ? OR issuingrules.itemtype = '*')
        AND
          (issuingrules.branchcode = ? OR issuingrules.branchcode = '*')
        ORDER BY
          issuingrules.categorycode desc,
          issuingrules.itemtype desc,
          issuingrules.branchcode desc

It returns (I don't know why !) the branch='*' rule.

This feature existed previously in biblibre/master, and got lost with some
other features during 3.2/3.4
We made it a different way, here is the piece of code:


    # This configuration table defines the order of inheritance. We'll loop
over it.
    my @attempts = (
        [ "*",           "*",       "*" ],
        [ "*",           $itemtype, "*" ],
        [ $categorycode, "*",       "*" ],
        [ $categorycode, $itemtype, "*" ],
        [ "*",           "*",       $branchcode ],
        [ "*",           $itemtype, $branchcode ],
        [ $categorycode, "*",       $branchcode ],
        [ $categorycode, $itemtype, $branchcode ],
    );

    # This complex query returns a nested hashref, so we can access a rule
using :
    # my $rule = $$rules{$categorycode}{$itemtype}{$branchcode};
    # this will be usefull in the inheritance computation code
    my $rules = $dbh->selectall_hashref(
        "SELECT * FROM issuingrules where branchcode IN ('*',?) and itemtype IN
('*', ?) and categorycode IN ('*',?)",
        [ "branchcode", "itemtype", "categorycode" ],
        undef, ( $branchcode, $itemtype, $categorycode )
    );

    # This block is for inheritance. It loops over rules returned by the
    # previous query. If a value is found in a more specific rule, it replaces
    # the old value from the more generic rule.
    my $oldrule;
    for my $attempt (@attempts) {
        if ( my $rule = $$rules{ @$attempt[2] }{ @$attempt[1] }{ @$attempt[0] }
) {
            if ($oldrule) {
                for ( keys %$oldrule ) {
                    if ( defined $rule->{$_} ) {
                        $oldrule->{$_} = $rule->{$_};
                    }
                }
            } else {
                $oldrule = $rule;
            }
        }
    }

=> we retrieve an array of all applicable rules, then we check each of them.
the last one we find is the more precise and should be used ! (it's in
"$oldrule", that is not a very good name I agree. It's the "appliedrule" in
fact.

Marking failed QA, will attach my follow-ups

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list