issue/5918 - Strict in_array() comparison for Settings API Select Multiple #5919
+1
−1
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.
Unless you do a strict comparison for
in_array()
it can cause unexpected<option>
s to be selected once the callback function completes.For example, if a Setting has the following saved:
And the following is available as
$args['options']
:The
<option>
s with values15
AND15-1
get selected. I suppose this is due to15
not containing any different characters than15-1
while15-2
does contain different characters. According to the PHP Docs, setting it to a Strict Comparison is meant to check against the Type of the Needle but it also forces it to match the entire String it would seem.#5918
Edit: PHP actually doesn't handle the Array key for the Value that way. The Int is an Int.