When autoMemberNum is enabled, Koha picks the next cardnumber as MAX(numeric cardnumber in borrowers) + 1. If patron A's auto-generated cardnumber is later changed (e.g. they get a physical card) or the patron is deleted, the original number becomes "free" and the next self-registrant is assigned it -- inheriting anything third-party services (OverDrive, Hoopla, unauthenticated self-check) have keyed on the cardnumber. This patch makes Koha::Patron::fixup_cardnumber use a monotonic counter (the autoMemberNumValue syspref) so that once a number has been auto-generated for any patron, it is never auto-generated again. The syspref row is locked with SELECT ... FOR UPDATE inside the existing txn_do, which serialises concurrent callers via InnoDB row-level locking and addresses the race condition raised against earlier revisions of this patch. The formula is: next = MAX(counter, db_max) + 1. When the counter is 0 (pre-upgrade or missing syspref), this degrades gracefully to db_max + 1 -- the legacy behaviour -- so no feature toggle is needed. The counter is only bumped when Koha actually auto-generates a cardnumber; plugin- or caller-supplied values do not touch it. Test plan: 1. Enable autoMemberNum. 2. Self-register patron A via OPAC, note cardnumber N. 3. Edit patron A in the staff interface, change cardnumber to something non-numeric like "MANUAL-XYZ". 4. Self-register patron B. 5. Confirm B gets N+1, NOT N. 6. Delete patron A. 7. Self-register patron C. 8. Confirm C gets N+2, NOT A's original number. 9. Install a plugin implementing the patron_barcode_transform hook; confirm it still runs and its value is honoured (counter is not bumped when the plugin supplies a cardnumber). Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk> |
||
|---|---|---|
| .github/workflows | ||
| C4 | ||
| Koha | ||
| acqui | ||
| admin | ||
| api | ||
| authorities | ||
| basket | ||
| bin | ||
| bookings | ||
| catalogue | ||
| cataloguing | ||
| circ | ||
| clubs | ||
| course_reserves | ||
| debian | ||
| docs | ||
| erm | ||
| errors | ||
| etc | ||
| ill | ||
| installer | ||
| koha-tmpl | ||
| labels | ||
| lib | ||
| members | ||
| misc | ||
| offline_circ | ||
| opac | ||
| patron_lists | ||
| patroncards | ||
| plugins | ||
| pos | ||
| preservation | ||
| recalls | ||
| reports | ||
| reserve | ||
| reviews | ||
| rotating_collections | ||
| serials | ||
| services | ||
| skel | ||
| suggestion | ||
| svc | ||
| t | ||
| tags | ||
| tools | ||
| virtualshelves | ||
| xt | ||
| .editorconfig | ||
| .gitignore | ||
| .htaccess | ||
| .mailmap | ||
| .perlcriticrc | ||
| .perltidyrc | ||
| .prettierrc.js | ||
| .proverc.dist | ||
| .stylelintrc.json | ||
| INSTALL | ||
| Koha.pm | ||
| LICENSE | ||
| MANIFEST.SKIP | ||
| Makefile.PL | ||
| README | ||
| README.md | ||
| README.robots | ||
| SECURITY.md | ||
| about.pl | ||
| app.psgi | ||
| build-resources.PL | ||
| changelanguage.pl | ||
| cpanfile | ||
| cypress.config.ts | ||
| eslint.config.mjs | ||
| fix-perl-path.PL | ||
| gulpfile.js | ||
| help.pl | ||
| kohaversion.pl | ||
| mainpage.pl | ||
| package.json | ||
| rewrite-config.PL | ||
| rspack.config.js | ||
| tsconfig.json | ||
| webpack.config.js | ||
| yarn.lock | ||
README.md
Koha is a free software integrated library system (ILS).
Koha is distributed under the GNU GPL version 3 or later.
Note: Koha does not accept pull requests from git hosting sites.
Note: This project has its own bug tracker, to report a bug or submit a patch visit http://bugs.koha-community.org.
For guidelines on submitting patches for Koha please visit https://wiki.koha-community.org/wiki/SubmitingAPatch
The developers handbook can be found at https://wiki.koha-community.org/wiki/Developer_handbook
