Fix register_patron subject length validation and postal_code mapping in updatePatron - #181
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issues in patron registration/update flows by loosening email subject validation and ensuring ZIP + city/state fields are preserved/mapped correctly when updating patrons using data sourced from getPatronAttributes().
Changes:
- Increased
registerPatron()email subject length validation froms:20tos:128. - Enhanced
checkAliases()to fallback-mapzip/postal_code→ZIPandcity+state/city_state→CITY/STATE. - Updated sample YAML to fix a ZIP validation typo and to allow the
ONLINEprofile; updated unit test to assert ZIP mapping.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Libilsws.php |
Adjusts subject validation limit and adds ZIP/CITY/STATE fallback alias mapping to prevent address data loss during updates. |
tests/Unit/LibilswsTest.php |
Extends getPatronAttributes() unit test coverage to assert ZIP is extracted into zip. |
libilsws.yaml.sample |
Fixes ZIP validation typo (97032r97034 → `97032 |
legacy_tests/register_patron.php |
Expands legacy script to fetch and print patron attributes after registration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1960
to
+1974
| if (empty($patron['ZIP'])) { | ||
| if (isset($patron['zip'])) { | ||
| $patron['ZIP'] = $patron['zip']; | ||
| } elseif (isset($patron['postal_code'])) { | ||
| $patron['ZIP'] = $patron['postal_code']; | ||
| } | ||
| } | ||
|
|
||
| if (empty($patron['CITY/STATE'])) { | ||
| if (isset($patron['city_state'])) { | ||
| $patron['CITY/STATE'] = $patron['city_state']; | ||
| } elseif (isset($patron['city']) && isset($patron['state'])) { | ||
| $patron['CITY/STATE'] = $patron['city'] . ', ' . $patron['state']; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes two main issues identified in patron registration and update flows:
Libilsws::registerPatronfroms:20tos:128to allow standard registration email subjects like 'Welcome to our library!'.97032r97034->97032|97034inlibilsws.yaml.sample.Libilsws::checkAliasesto fallback-mapzip->ZIPandcity/state->CITY/STATE. This preventsupdatePatron()from omitting address fields and erasing the Zip Code when updating a record retrieved viagetPatronAttributes().ONLINEprofile tooverlay_fields.profile.validationinlibilsws.yaml.sample.Verification
./vendor/bin/phpunit).category02toTEXTviaupdatePatron(), and verified all fields includingzipremain preserved.