https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21052

--- Comment #6 from Chris Nighswonger 
<[email protected]> ---
Patch attached.

Root cause: printers_profile carries a UNIQUE key on (printer_name,
template_id, paper_bin, creator). Neither profile editor validated that the
printer name and paper bin were supplied, so a blank field was stored as an
empty string. The first blank save succeeded; a second collided on the unique
key and the resulting Koha::Exceptions::Object::DuplicateID went unhandled,
giving a bare 500 error page.

Both editors now trim and validate the two required fields, catch DuplicateID
and re-render with a warning, and check save()'s -1 failure return rather than
redirecting as though the save had worked. A profile deleted between opening
the edit form and saving it also no longer 500s. Rows already left behind by
this bug can now be repaired in place -- a blank stored value renders as an
editable input rather than read-only, which it previously was.

Also worth noting for testers: the new-profile form now arrives pre-filled with
'Default Printer' and 'Tray 1'. Those defaults have been in
C4::Creators::Profile->new() all along, but the create branch of both templates
emitted an input with no value attribute, so the user saw two empty boxes and
an
untouched save stored empty strings. The value attribute has to be added anyway
so that what the user typed survives an error redisplay; surfacing the defaults
is a side effect of that, and is what they were for.

Reproduced and verified in koha-testing-docker on both editors, before and
after: blank fields, whitespace-only values, duplicate name+bin, cleared
numeric fields, repairing a legacy blank row, and a concurrent delete -- no
500s remain in either editor. prove t/db_dependent/Labels/
t/db_dependent/Creators/ t/Creators.t -- 870 tests pass. koha-qa.pl PASS.

Two follow-ups are filed rather than folded in here: bug 43191 (cleaning up
profiles already saved with a blank value) and bug 43193 (non-numeric offset or
creep text, a different defect class).

Internal review: https://github.com/cnighswonger/koha-wip/pull/96

An AI tool assisted with the investigation and fix; full detail is in the
commit
message, and all work was reviewed by me.

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to