fix: use sanitized value in unique field check - #7628
Open
faisalahammad wants to merge 1 commit into
Open
Conversation
The unique field check built its query prepare array with $check_value before that variable was assigned, which raised an undefined variable warning and silently disabled unique enforcement on table storage pods. Move the pods_sanitize() call above the prepare array so the query gets the sanitized value. Fixes pods-framework#7623
faisalahammad
requested review from
JoryHogeveen and
sc0ttkclark
as code owners
September 11, 2026 20:24
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.
AI disclosure: this PR was written with GLM 5.3 flash assistance, reviewed and tested by me.
Description
Unique field validation in
PodsAPI::handle_field_validation()built its query prepare array with$check_valuebefore that variable was assigned. The$check_value = pods_sanitize( $value )call sat a few lines below the$prepareconstruction, so the query always received an undefined variable. This raised a PHP "Undefined variable $check_value" warning and silently disabled unique enforcement on table storage pods, including Advanced Content Types.The fix moves the
pods_sanitize()call above the$preparearray so the uniqueness query receives the sanitized value. Pick and other tableless field types are unaffected because they take the separate tableless branch and never reach this code path.Backward compatible: yes, no breaking changes.
Related GitHub issue(s)
Fixes #7623
Testing instructions
person) with table storage.social_security_number) and enable "Unique" under its Advanced settings.123-45-6789.WP_DEBUG_DISPLAYenabled.PHP Warning: Undefined variable $check_valueappears in the logs.Tested manually: confirmed this resolves the reported issue.
Screenshots / screencast
Not applicable, no UI changes.
Changelog text for these changes
Bug: Fixed Unique field validation so the sanitized value is used in the uniqueness query. Unique fields on table storage pods now correctly block duplicate values and no longer trigger a PHP warning. #7623 (@faisalahammad)
PR checklist