biblionumbers and biblioitemnumbers are out of sync in some libraries and this creates bug with misc/batchRebuildBiblioTables.pl (and probably others some features). To reproduce : - change AUTO_INCREMENT in TABLE biblioitems to be different than biblionumber (eg. if last biblionumber is 5000 : "SET FOREIGN_KEY_CHECKS=OFF;ALTER TABLE biblioitems AUTO_INCREMENT = 5002;SET FOREIGN_KEY_CHECKS=ON;") - create one or more new bib records (with items) - see mysql records : SELECT biblio.biblionumber AS bibbiblionumber, biblioitems.biblionumber AS bibitemsbiblionumber, biblioitems.biblioitemnumber AS bibitemsbiblioitemnumber, items.biblionumber AS itemsbiblionumber, items.biblioitemnumber AS itemsbiblioitemnumber, biblioitems.publishercode, biblio.title, items.barcode FROM biblioitems JOIN biblio ON biblio.biblionumber=biblioitems.biblionumber JOIN items ON biblioitems.biblionumber=items.biblionumber WHERE biblio.biblionumber>5000; #before batchRebuildBiblioTables +-----------------+----------------------+--------------------------+-------------------+-----------------------+----------------+--------------+-----------------+ | bibbiblionumber | bibitemsbiblionumber | bibitemsbiblioitemnumber | itemsbiblionumber | itemsbiblioitemnumber | publishercode | title | barcode | +-----------------+----------------------+--------------------------+-------------------+-----------------------+----------------+--------------+-----------------+ | 5001 | 5001 | 5002 | 5001 | 5002 | editeur test 0 | Titre test 0 | barcode testa 0 | | 5002 | 5002 | 5003 | 5002 | 5003 | editeur test 1 | Titre test 1 | barcode testa 1 | | 5003 | 5003 | 5004 | 5003 | 5004 | editeur test 2 | Titre test 2 | barcode testa 2 | | 5004 | 5004 | 5005 | 5004 | 5005 | editeur test 3 | Titre test 3 | barcode testa 3 | | 5005 | 5005 | 5006 | 5005 | 5006 | editeur test 4 | Titre test 4 | barcode testa 4 | | 5006 | 5006 | 5007 | 5006 | 5007 | editeur test 5 | Titre test 5 | barcode testa 5 | | 5007 | 5007 | 5008 | 5007 | 5008 | editeur test 6 | Titre test 6 | barcode testa 6 | | 5008 | 5008 | 5009 | 5008 | 5009 | editeur test 7 | Titre test 7 | barcode testa 7 | | 5009 | 5009 | 5010 | 5009 | 5010 | editeur test 8 | Titre test 8 | barcode testa 8 | | 5010 | 5010 | 5011 | 5010 | 5011 | editeur test 9 | Titre test 9 | barcode testa 9 | +-----------------+----------------------+--------------------------+-------------------+-----------------------+----------------+--------------+-----------------+ - run ~/src/misc/batchRebuildBiblioTables.pl -c - see mysql records : SELECT biblio.biblionumber AS bibbiblionumber, biblioitems.biblionumber AS bibitemsbiblionumber, biblioitems.biblioitemnumber AS bibitemsbiblioitemnumber, items.biblionumber AS itemsbiblionumber, items.biblioitemnumber AS itemsbiblioitemnumber, biblioitems.publishercode, biblio.title, items.barcode FROM biblioitems JOIN biblio ON biblio.biblionumber=biblioitems.biblionumber JOIN items ON biblioitems.biblionumber=items.biblionumber WHERE biblio.biblionumber>5000; #after batchRebuildBiblioTables +-----------------+----------------------+--------------------------+-------------------+-----------------------+----------------+--------------+-----------------+ | bibbiblionumber | bibitemsbiblionumber | bibitemsbiblioitemnumber | itemsbiblionumber | itemsbiblioitemnumber | publishercode | title | barcode | +-----------------+----------------------+--------------------------+-------------------+-----------------------+----------------+--------------+-----------------+ | 5002 | 5002 | 5002 | 5002 | 5003 | editeur test 1 | Titre test 1 | barcode testa 1 | | 5003 | 5003 | 5003 | 5003 | 5004 | editeur test 2 | Titre test 2 | barcode testa 2 | | 5004 | 5004 | 5004 | 5004 | 5005 | editeur test 3 | Titre test 3 | barcode testa 3 | | 5005 | 5005 | 5005 | 5005 | 5006 | editeur test 4 | Titre test 4 | barcode testa 4 | | 5006 | 5006 | 5006 | 5006 | 5007 | editeur test 5 | Titre test 5 | barcode testa 5 | | 5007 | 5007 | 5007 | 5007 | 5008 | editeur test 6 | Titre test 6 | barcode testa 6 | | 5008 | 5008 | 5008 | 5008 | 5009 | editeur test 7 | Titre test 7 | barcode testa 7 | | 5009 | 5009 | 5009 | 5009 | 5010 | editeur test 8 | Titre test 8 | barcode testa 8 | | 5010 | 5010 | 5010 | 5010 | 5011 | editeur test 9 | Titre test 9 | barcode testa 9 | | 5010 | 5010 | 5011 | 5010 | 5011 | editeur test 9 | Titre test 9 | barcode testa 9 | +-----------------+----------------------+--------------------------+-------------------+-----------------------+----------------+--------------+-----------------+ result : - first desynchronized biblionumber disappeared - biblioitems.biblioitemnumber have been updated to be identical to biblionumber - for one biblionumber : biblioitemnumber is not the same in biblioitems and items table cause : . in C4::Biblio : GetMarcBiblio calls _koha_marc_update_bib_ids with the wrong arguments : ("$record, '', $biblionumber, $biblionumber") instead of ("$record, $frameworkcode, $biblionumber, $biblioitemnumber")
I think no piece of code should assume that biblionumber and biblioitemnumber are in sync. They are just id's on tables.
*** This bug has been marked as a duplicate of bug 10961 ***