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

(-)a/installer/data/mysql/updatedatabase.pl (-1 / +40 lines)
Lines 11351-11356 if(CheckVersion($DBversion)) { Link Here
11351
    SetVersion($DBversion);
11351
    SetVersion($DBversion);
11352
}
11352
}
11353
11353
11354
$DBversion = "3.21.00.XXX";
11355
if ( CheckVersion($DBversion) ) {
11356
11357
    $sth = $dbh->prepare(q{
11358
     SELECT s.itemnumber, i.itype, b.itemtype FROM
11359
      ( SELECT DISTINCT itemnumber
11360
        FROM statistics
11361
        WHERE type="return" AND itemtype IS NULL ) s
11362
      LEFT JOIN
11363
      ( SELECT itemnumber,biblionumber, itype
11364
        FROM items ) i
11365
      ON (s.itemnumber=i.itemnumber)
11366
      LEFT JOIN
11367
      ( SELECT biblionumber, itemtype
11368
        FROM biblioitems ) b
11369
      ON (i.biblionumber=b.biblionumber)
11370
    });
11371
    $sth->execute();
11372
11373
    my $update_sth = $dbh->prepare(q{
11374
        UPDATE statistics
11375
        SET itemtype=?
11376
        WHERE itemnumber=? AND itemtype IS NULL
11377
    });
11378
    my $ilevel_itypes = C4::Context->preference('item-level_itypes');
11379
11380
    while ( my ($itemnumber,$item_itype,$biblio_itype) = $sth->fetchrow_array ) {
11381
11382
        my $effective_itemtype = $ilevel_itypes
11383
                                    ? $item_itype // $biblio_itype
11384
                                    : $biblio_itype;
11385
        warn "item-level_itypes set but no itype defined for item ($itemnumber)"
11386
            if $ilevel_itypes and !defined $item_itype;
11387
        $update_sth->execute( $effective_itemtype, $itemnumber );
11388
    }
11389
11390
    print "Upgrade to $DBversion done (Bug 14598: itemtype is not set on statistics by C4::Circulation::AddReturn)\n";
11391
    SetVersion($DBversion);
11392
}
11393
11354
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11394
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11355
# SEE bug 13068
11395
# SEE bug 13068
11356
# if there is anything in the atomicupdate, read and execute it.
11396
# if there is anything in the atomicupdate, read and execute it.
11357
- 

Return to bug 14598