https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44309 --- Comment #1 from Jacob O'Mara <jacob.omara@openfifth.co.uk> --- Created attachment 212695 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212695&action=edit Bug 44309: Match hbyymmincr barcodes against real library codes This patch changes C4::Barcodes::ValueBuilder::hbyymmincr::get_barcode so that it only counts barcodes made of a real library code, then yymm, then exactly 4 digits. It uses one LIKE filter for each library code, so the query uses the barcode index and does not scan the full items table. Test plan: 1. Set the autoBarcode system preference to "generated in the form <branchcode>yymm0001". 2. Find the current year and month as yymm (for example 2611 for November 2026). 3. Edit an item and set its barcode to CPL<yymm>0001 (for example CPL26110001). 4. Edit a different item and set its barcode to 1234567<yymm>9999 (for example 123456726119999). 5. Open a bibliographic record and click New > New item. Make sure the home library is Centerville (CPL). 6. Click in the barcode field (952$p). => The barcode is CPL<yymm>0001. 7. Click "Add item". => The item is not saved, because the barcode is not unique. 8. Apply the patch and restart_all. 9. Repeat steps 5 and 6. => The barcode is CPL<yymm>0002. 10. Click "Add item". => The item is saved. 11. Run: prove t/db_dependent/Barcodes_ValueBuilder.t => All tests pass. Assisted-by: Claude Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.