[Koha-bugs] [Bug 17642] Authorised values code is broken because of the refactoring

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Nov 16 11:48:45 CET 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17642

--- Comment #1 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
>From bug 17250 comment 16:

This code (C4/Items.pm, line 1378):

    # get notforloan complete status if applicable
    $av = Koha::AuthorisedValues->search_by_koha_field({
         frameworkcode => $data->{frameworkcode},
         kohafield => 'items.notforloan',
         authorised_value => $data->{itemnotforloan}
    });
    $av = $av->count ? $av->next : undef;

(and the next two similar statements below, for items.restricted and
items.stack) doesn't work for me as expected. I'm testing on current master;
same problem[s] on jessie and wheezy.

If authorised value code in a given item record is undef|NULL or 0
(items.itemnotfoloan is most often 0, items.restricted is usually NULL -
depends on the database contents), ->search_by_koha_field->count returns more
then 1, and ->next returns some random (usually the 1st one in DB, but it's not
guaranteed) AV record, eg. with result description being 'Ordered' for
item.itemnoforloan = 0.

If itemnoforloan in item record is not null and not zero, e.g. 1 or -1 (= item
not for loan, item ordered), $av->count fails (it's not a fatal error) with the
following warnings in the logs:

DBD::mysql::st execute failed: Column 'authorised_value' in where clause is
ambiguous [for Statement "SELECT COUNT( * ) FROM (SELECT `me`.`id`,
`me`.`category`, `me`.`authorised_value`, `me`.`lib`, `me`.`lib_opac`,
`me`.`imageurl` FROM `authorised_values` `me`  JOIN
`authorised_value_categories` `category` ON `category`.`category_name` =
`me`.`category` LEFT JOIN `marc_subfield_structure` `marc_subfield_structures`
ON `marc_subfield_structures`.`authorised_value` = `category`.`category_name`
WHERE ( ( `authorised_value` = ? AND `marc_subfield_structures`.`frameworkcode`
= ? AND `marc_subfield_structures`.`kohafield` = ? ) ) GROUP BY `me`.`id`,
`me`.`category`, `me`.`authorised_value`, `me`.`lib`, `me`.`lib_opac`,
`me`.`imageurl`) `me`" with ParamValues: 0=-1, 1='', 2='items.notforloan'] at
/usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.
No method count found for Koha::AuthorisedValues
DBIx::Class::Storage::DBI::_dbh_execute(): Column 'authorised_value' in where
clause is ambiguous at /home/koha/devkohaclone/Koha/Objects.pm line 307

and the result AV descriptions are empty strings.

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


More information about the Koha-bugs mailing list