[Bug 42161] New: Non-mandatory patron attribute type does not appear in members-update.pl
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Bug ID: 42161 Summary: Non-mandatory patron attribute type does not appear in members-update.pl Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: aude.charillon@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle@bywatersolutions.com Modifying a non-mandatory patron attribute type in the OPAC is not taken into account in the Update patron records page in the staff interface, when the field was blank at the point of self-registration and has never been updated in the staff interface. To replicate: 1. Create a mandatory patron attribute type: go to Administration > Patron attribute types > New. For example, give it code NEWS and description 'Receive newsletter?' Tick: Display in OPAC, Editable in OPAC, OPAC mandatory. 2. Create a non-mandatory patron attribute type: go to Administration > Patron attribute types > New. For example, give it code SUPREQ and description 'Support requirements'. Tick: Display in OPAC, Editable in OPAC. 3. Set up self-registration: set the PatronSelfRegistration system preference to 'Allow'. 4. Make sure PatronSelfRegistrationDefaultCategory is filled with a patron category. 5. Set the OPACPatronDetails system preference to 'Allow'. 6. Go to the OPAC > Create an account (opac-memberentry.pl) and add some details. Under Additional information, enter a value for 'Receive newsletter?' but leave 'Support requirements' blank. Submit. 7. Login to the OPAC with your newly-registered patron. 8. In the personal details tab, add a value solely for 'Support requirements'. Submit update request. 9. From the staff interface homepage, click Patrons requesting modifications (members-update.pl). 10. A request for the patron created in step 6 appears, with a section entitled Additional attributes and identifiers. There is one row Field = Newsletter; old value and new value are the same. Note that we did not update Newsletter in step 8; this row should not appear. Note that we added a value for Support requirements in step 8: this does not appear; this is the bug being reported. 11. Approve the update request: tick Approve then click Submit. 12. In the staff interface, go to the patron acccount. Note that the Support requirements field is still empty. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #1 from Aude Charillon <aude.charillon@openfifth.co.uk> --- I also tested: A. Updating the mandatory patron attribute: this works. B. Updating both the mandatory and non-mandatory attribute: only the mandatory is taken into account in steps 10-12. C. Updating the non-mandatory patron attribute in the staff interface: the value correctly appears in the OPAC. Repeating steps 8 to 12: this time, the updated value does correctly display at step 10 in members-update.pl and at step 12 in the patron record. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 lucy.farnsworth@nhs.net changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucy.farnsworth@nhs.net -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199331 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199331&action=edit Bug 42161: Fix identify_updated_extended_attributes for patrons with no prior attributes Two bugs in identify_updated_extended_attributes caused OPAC patron attribute updates to be silently lost: 1. $patron_attribute_types and $passed_attribute_types were declared as undef rather than empty hashrefs. When a patron had zero existing opac_editable attributes, `keys %{undef}` raised a fatal error, swallowing the modification request entirely. 2. The `any` check when comparing values did not filter by attribute code. If any other submitted attribute happened to share the same value as the existing value being tested (e.g. two empty-string attributes), the change was incorrectly treated as a no-op. Adds two new test cases covering both failure modes. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk Severity|enhancement |normal CC| |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Sponsorship status|--- |Sponsored Patch complexity|--- |Trivial patch Comma delimited| |OpenFifth list of Sponsors| |<https://openfifth.co.uk/> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #199331|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 199332 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199332&action=edit Bug 42161: Fix identify_updated_extended_attributes for patrons with no prior attributes Two bugs in identify_updated_extended_attributes caused OPAC patron attribute updates to be silently lost: 1. $patron_attribute_types and $passed_attribute_types were declared as undef rather than empty hashrefs. When a patron had zero existing opac_editable attributes, `keys %{undef}` raised a fatal error, swallowing the modification request entirely. 2. The `any` check when comparing values did not filter by attribute code. If any other submitted attribute happened to share the same value as the existing value being tested (e.g. two empty-string attributes), the change was incorrectly treated as a no-op. Adds two new test cases covering both failure modes. Sponsored-by: OpenFifth <https://openfifth.co.uk/> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #199332|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #4 from David Nind <david@davidnind.com> --- Created attachment 202137 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202137&action=edit Bug 42161: Fix identify_updated_extended_attributes for patrons with no prior attributes Two bugs in identify_updated_extended_attributes caused OPAC patron attribute updates to be silently lost: 1. $patron_attribute_types and $passed_attribute_types were declared as undef rather than empty hashrefs. When a patron had zero existing opac_editable attributes, `keys %{undef}` raised a fatal error, swallowing the modification request entirely. 2. The `any` check when comparing values did not filter by attribute code. If any other submitted attribute happened to share the same value as the existing value being tested (e.g. two empty-string attributes), the change was incorrectly treated as a no-op. Adds two new test cases covering both failure modes. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #5 from David Nind <david@davidnind.com> --- I've signed off, even though I can't reproduce the issue in current main (as at 19 July 2026). Both before and after the patch things work as expected for me. The tests pass prove t/db_dependent/Koha/Patron.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |lisette@bywatersolutions.co |y.org |m CC| |lisette@bywatersolutions.co | |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrew@bywatersolutions.com --- Comment #7 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- (In reply to Lisette Scheer from comment #6)
I also can't recreate, everything works as expected for me before applying patches.
Same, this works as expected without patches. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA --- Comment #8 from Lisette Scheer <lisette@bywatersolutions.com> --- Failing QA since it works before patches -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 209586 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209586&action=edit Bug 42161: Fix OPAC attribute changes lost in identify_updated_extended_attributes -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Thanks everyone for testing, and Lisette's Failed QA was fair: the issue does not reproduce with the steps in comment 0. I have gone back through it properly and the original patch overstated things: - The claimed fatal error (keys %{undef}) for a patron with no existing attributes is wrong. The hashes autovivify, so that case already works on main. I have dropped that change and its test. - The second claim, that the value comparison does not filter by attribute code, is a real bug. The steps in comment 0 do not trigger it, because only one non-mandatory attribute is left blank there. It is triggered when the stored value of an attribute equals the submitted value of a different attribute. The typical case is a patron who self-registered leaving two non-mandatory attributes blank: both are stored with an empty value, and setting one of them in the OPAC later is ignored because the other is still submitted as empty. If nothing else changed, no modification request is created at all. I reproduced this on current main at the Koha::Patron level in KTD: stored ONE='' and TWO='', submitted ONE='' and TWO='wheelchair' returns no changes on main, and returns the change to TWO with the patch. I have not clicked through the OPAC and staff interface, so please shout if the new test plan does not behave as described. New patch attached (rebased on current main): - the commit message now describes only the real bug - the two new tests both fail without the fix and pass with it, and they check which attribute is returned, not just the count - the test plan uses two blank attributes The earlier signed-off patch is obsoleted as the code and tests changed, so this needs a fresh sign-off. Sorry for the noise. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #202137|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #209586|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #11 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 209590 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209590&action=edit Bug 42161: Fix OPAC attribute changes lost in identify_updated_extended_attributes When a patron edits their attributes in the OPAC, identify_updated_extended_attributes compares each stored attribute with the submitted ones. For an attribute type that has the same number of values stored and submitted, it checks that the stored value is among the submitted values, but it looked at the submitted values of all attribute types instead of only those of the type being checked. So if the old value of an attribute equalled the submitted value of any other attribute, the change was treated as "nothing changed" and was silently lost. The typical case is a patron who self-registered leaving two non-mandatory attributes blank: both are stored with an empty value, and setting one of them in the OPAC later is ignored because the other is still submitted as empty. If nothing else changed, no modification request is created at all. Only compare against the submitted values of the same attribute type. Test plan: 1. Create two patron attribute types, e.g. codes ONE and TWO, with "Display in OPAC" and "Editable in OPAC" ticked, and none of the mandatory options. 2. Set PatronSelfRegistration to 'Allow', make sure PatronSelfRegistrationDefaultCategory is set, and set OPACPatronDetails to 'Allow'. 3. In the OPAC, go to 'Create an account' and fill in the required details. Under 'Additional information' leave both ONE and TWO blank. Submit. 4. Log in to the OPAC as the new patron, using the password shown on the confirmation page. 5. In the 'Personal details' tab, enter a value for TWO only and submit the update request. 6. In the staff interface, go to 'Patrons requesting modifications' (members-update.pl) => Without the patch there is no request for the patron: the change to TWO was lost. => With the patch the request is listed, with TWO under 'Additional attributes and identifiers'. Approve it and check that the patron has the value for TWO. 7. Run $ prove t/db_dependent/Koha/Patron.t => The new tests in the identify_updated_extended_attributes subtest fail without the patch and pass with it. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #209590|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #12 from David Nind <david@davidnind.com> --- Created attachment 209629 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209629&action=edit Bug 42161: Fix OPAC attribute changes lost in identify_updated_extended_attributes When a patron edits their attributes in the OPAC, identify_updated_extended_attributes compares each stored attribute with the submitted ones. For an attribute type that has the same number of values stored and submitted, it checks that the stored value is among the submitted values, but it looked at the submitted values of all attribute types instead of only those of the type being checked. So if the old value of an attribute equalled the submitted value of any other attribute, the change was treated as "nothing changed" and was silently lost. The typical case is a patron who self-registered leaving two non-mandatory attributes blank: both are stored with an empty value, and setting one of them in the OPAC later is ignored because the other is still submitted as empty. If nothing else changed, no modification request is created at all. Only compare against the submitted values of the same attribute type. Test plan: 1. Create two patron attribute types, e.g. codes ONE and TWO, with "Display in OPAC" and "Editable in OPAC" ticked, and none of the mandatory options. 2. Set PatronSelfRegistration to 'Allow', make sure PatronSelfRegistrationDefaultCategory is set, and set OPACPatronDetails to 'Allow'. 3. In the OPAC, go to 'Create an account' and fill in the required details. Under 'Additional information' leave both ONE and TWO blank. Submit. 4. Log in to the OPAC as the new patron, using the password shown on the confirmation page. 5. In the 'Personal details' tab, enter a value for TWO only and submit the update request. 6. In the staff interface, go to 'Patrons requesting modifications' (members-update.pl) => Without the patch there is no request for the patron: the change to TWO was lost. => With the patch the request is listed, with TWO under 'Additional attributes and identifiers'. Approve it and check that the patron has the value for TWO. 7. Run $ prove t/db_dependent/Koha/Patron.t => The new tests in the identify_updated_extended_attributes subtest fail without the patch and pass with it. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #13 from David Nind <david@davidnind.com> --- Testing notes (using KTD): 1. Step 2: In KTD by default PatronSelfRegistration is set to "Allow", "PatronSelfRegistrationDefaultCategory" is set to "Self registration", and OPACPatronDetails is set to "Allow". 2. Step 5: Message shown in the OPAC before the patch and after an update to attribute "TWO" is "No changes were made." - Note: Adding a value to the first attribute only (ONE) does the same thing, only submits change if values in both attributes. 3. Step 7: Before the patch, the test pass (only way to test this is if the updated tests are in a separate patch, or to manually apply the changes). 4. After the patch, all combinations of adding, editing, and removing values for attributes ONE and TWO work as expected for me, including: - Add values to both attributes: Success - Add value for attribute ONE only: Success - Add value for attribute TWO only: Success - Removing values (all, ONE and TWO separately) - Editing values (all, ONE and TWO separately) Success = - Message in OPAC: "Your updates have been submitted. A librarian will review your updates before applying them." - Notification about changes required reviewing appear in staff interface, with "Patrons requesting modifications" notification on the home page. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA --- Comment #14 from Lisette Scheer <lisette@bywatersolutions.com> --- Martin, thanks that works great and I was able to recreate on main. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #209629|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42161 --- Comment #15 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 209636 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209636&action=edit Bug 42161: Fix OPAC attribute changes lost in identify_updated_extended_attributes When a patron edits their attributes in the OPAC, identify_updated_extended_attributes compares each stored attribute with the submitted ones. For an attribute type that has the same number of values stored and submitted, it checks that the stored value is among the submitted values, but it looked at the submitted values of all attribute types instead of only those of the type being checked. So if the old value of an attribute equalled the submitted value of any other attribute, the change was treated as "nothing changed" and was silently lost. The typical case is a patron who self-registered leaving two non-mandatory attributes blank: both are stored with an empty value, and setting one of them in the OPAC later is ignored because the other is still submitted as empty. If nothing else changed, no modification request is created at all. Only compare against the submitted values of the same attribute type. Test plan: 1. Create two patron attribute types, e.g. codes ONE and TWO, with "Display in OPAC" and "Editable in OPAC" ticked, and none of the mandatory options. 2. Set PatronSelfRegistration to 'Allow', make sure PatronSelfRegistrationDefaultCategory is set, and set OPACPatronDetails to 'Allow'. 3. In the OPAC, go to 'Create an account' and fill in the required details. Under 'Additional information' leave both ONE and TWO blank. Submit. 4. Log in to the OPAC as the new patron, using the password shown on the confirmation page. 5. In the 'Personal details' tab, enter a value for TWO only and submit the update request. 6. In the staff interface, go to 'Patrons requesting modifications' (members-update.pl) => Without the patch there is no request for the patron: the change to TWO was lost. => With the patch the request is listed, with TWO under 'Additional attributes and identifiers'. Approve it and check that the patron has the value for TWO. 7. Run $ prove t/db_dependent/Koha/Patron.t => The new tests in the identify_updated_extended_attributes subtest fail without the patch and pass with it. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org