Description
Andrew Fuerste-Henry
2025-07-21 14:21:40 UTC
It'd be great to have this patched on 24.11. While we can ask staff to not use the sectional edit buttons, they inevitably will, so we risk losing data. Created attachment 184449 [details] [review] Bug 40459: Preferred name is lost when editing partial record to test: * on the patron page click edit at the top, entered a preferred name, and hit save * we should see the preferred name being displayed instead of the first name for the user * go back @Imani: Commenting out the test for preferred_name entirely causes some unexpected behavior if any preferred_names are set and then you change BorrowerUnwantedField to exclude preferred_name. In this case you will no longer be able to edit the preferred_name, and changing the patron's firstname will no change the preferred name, A better solution would be to wrap the test for preferred_name in an if clause based on the $step variable passed from the form. $step = 0 if the full form is being edited. $step = 1 if the Contact Info portion is being edited. Anything else is a partial edit of the form elsewhere. (In reply to CJ Lynce from comment #3) > @Imani: Commenting out the test for preferred_name entirely causes some > unexpected behavior if any preferred_names are set and then you change > BorrowerUnwantedField to exclude preferred_name. In this case you will no > longer be able to edit the preferred_name, and changing the patron's > firstname will no change the preferred name, This is odd because elsewhere in the patron record any value set in a field that gets hidden via BorrowerUnwantedField is saved forever and cannot be edited from the patron record. But following that behavior for preferred_name would cause problems for patrons who change their firstnames, as their preferred_name would not update --and as soon as firstname and preferred_name do not match, Koha starts displaying preferred_name around the intranet and OPAC. (In reply to Andrew Fuerste-Henry from comment #4) > This is odd because elsewhere in the patron record any value set in a field > that gets hidden via BorrowerUnwantedField is saved forever and cannot be > edited from the patron record. But following that behavior for > preferred_name would cause problems for patrons who change their firstnames, > as their preferred_name would not update --and as soon as firstname and > preferred_name do not match, Koha starts displaying preferred_name around > the intranet and OPAC. Ideally, there would be a test to see if preferred_name is hidden BorrowerUnwantedField, and in that case, ignores, but doesnt change, the preferred_name field. This way, anything stored in preferred_name is preserved in the event its hidden then unhidden in the future. That said, without knowing exactly how preferred_name is handled throughout Koha, it is potentially a big undertaking to change this behavior. For the time being, though it doesn't really follow the behavior of other hidden/stored patron fields, the newdata{preferred_name} = undef unless defined $newdata{preferred_name} test helps to prevent a wrong preferred_name from being locked in if the field is hidden. Created attachment 184458 [details] [review] Bug 40459: Preferred name is lost when editing partial record to test: * follow test plan of previous patch * add preferred_name to BorrowerUnwantedField * updating the full patron or contact information field should update the preferred_name to the current first name Created attachment 184459 [details] [review] Bug 40459: Preferred name is lost when editing partial record To test: * on the patron page click edit at the top, entered a preferred name, and hit save * we should see the preferred name being displayed instead of the first name for the user * go back to the main edit page and change the preferred name to a blank space * We should revert back to the first name being used * if we open the edit page back up we should see the first name in the preferred name field * Edit the preferred name again and click on details * open up any of the sections other then contact information * hit the save button on the section without changing anything * you should still see the preferred name you set being used. * open up an individual section other then contact method, change a value, then save * you should still see the preferred name you set being used. * open up the contact information section and save without changing anything * the preferred name should be intact * open up the contact information and change the preferred name, and save. * you should see the new preferred name reflected. * Open up the contact information section, change the preferred name field to a blank and save. * you should see the first name being used now. * Open up the contact information section, and put any number of spaces in the preferred name with nothing else and then save. * you should still see the first name being used. Signed-off-by: CJ Lynce <cj.lynce@westlakelibrary.org> Patch works as intended both when preferred_name is not hidden, and when it is. I squashed both patches into one and cleaned up the test plan for good measure. Created attachment 184624 [details] [review] Bug 40459: Preferred name is lost when editing partial record To test: * on the patron page click edit at the top, entered a preferred name, and hit save * we should see the preferred name being displayed instead of the first name for the user * go back to the main edit page and change the preferred name to a blank space * We should revert back to the first name being used * if we open the edit page back up we should see the first name in the preferred name field * Edit the preferred name again and click on details * open up any of the sections other then contact information * hit the save button on the section without changing anything * you should still see the preferred name you set being used. * open up an individual section other then contact method, change a value, then save * you should still see the preferred name you set being used. * open up the contact information section and save without changing anything * the preferred name should be intact * open up the contact information and change the preferred name, and save. * you should see the new preferred name reflected. * Open up the contact information section, change the preferred name field to a blank and save. * you should see the first name being used now. * Open up the contact information section, and put any number of spaces in the preferred name with nothing else and then save. * you should still see the first name being used. Signed-off-by: CJ Lynce <cj.lynce@westlakelibrary.org> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Nice work everyone! Pushed to main for 25.11 Thanks Lucas! Can this be backported to 24.11.xx please? |