View | Details | Raw Unified | Return to bug 14598
Collapse All | Expand All

(-)a/installer/data/mysql/updatedatabase.pl (-1 / +40 lines)
Lines 10796-10801 if ( CheckVersion($DBversion) ) { Link Here
10796
    SetVersion($DBversion);
10796
    SetVersion($DBversion);
10797
}
10797
}
10798
10798
10799
$DBversion = "3.21.00.XXX";
10800
if ( CheckVersion($DBversion) ) {
10801
10802
    $sth = $dbh->prepare(q{
10803
     SELECT s.itemnumber, i.itype, b.itemtype FROM
10804
      ( SELECT DISTINCT itemnumber
10805
        FROM statistics
10806
        WHERE type="return" AND itemtype IS NULL ) s
10807
      LEFT JOIN
10808
      ( SELECT itemnumber,biblionumber, itype
10809
        FROM items ) i
10810
      ON (s.itemnumber=i.itemnumber)
10811
      LEFT JOIN
10812
      ( SELECT biblionumber, itemtype
10813
        FROM biblioitems ) b
10814
      ON (i.biblionumber=b.biblionumber)
10815
    });
10816
    $sth->execute();
10817
10818
    my $update_sth = $dbh->prepare(q{
10819
        UPDATE statistics
10820
        SET itemtype=?
10821
        WHERE itemnumber=? AND itemtype IS NULL
10822
    });
10823
    my $ilevel_itypes = C4::Context->preference('item-level_itypes');
10824
10825
    while ( my ($itemnumber,$item_itype,$biblio_itype) = $sth->fetchrow_array ) {
10826
10827
        my $effective_itemtype = $ilevel_itypes
10828
                                    ? $item_itype // $biblio_itype
10829
                                    : $biblio_itype;
10830
        warn "item-level_itypes set but no itype defined for item ($itemnumber)"
10831
            if $ilevel_itypes and !defined $item_itype;
10832
        $update_sth->execute( $effective_itemtype, $itemnumber );
10833
    }
10834
10835
    print "Upgrade to $DBversion done (Bug 14598: itemtype is not set on statistics by C4::Circulation::AddReturn)\n";
10836
    SetVersion($DBversion);
10837
}
10838
10799
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10839
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10800
# SEE bug 13068
10840
# SEE bug 13068
10801
# if there is anything in the atomicupdate, read and execute it.
10841
# if there is anything in the atomicupdate, read and execute it.
10802
- 

Return to bug 14598