Fix: save_profile_settings drops every site after the first on PHP 8#72
Open
svandragt wants to merge 1 commit into
Open
Fix: save_profile_settings drops every site after the first on PHP 8#72svandragt wants to merge 1 commit into
svandragt wants to merge 1 commit into
Conversation
The inner loop body reassigned $options via array_keys(), shadowing the outer foreach's $options binding. After the first site iteration the variable became a numerically-indexed array, so subsequent calls to in_array($value, $options) compared strings like 'all' against ints like 0 and 1. PHP 7 loose-equated those via int cast (true); PHP 8 reversed the rule to cast the int to string instead, so the check fails and every site after the first is silently skipped. Use a fresh local ($valid_values) and switch to a strict in_array(). Verified on PHP 8.3: profile-page save now persists for all sites in the network table, not just the first. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Falcon_Connector::save_profile_settings()shadow-mutated the outer foreach's$optionsto a numeric-indexed array. On the second and subsequent sites in the network profile-page save, the validity check becamein_array($value, [0, 1]).On PHP 7 the string→int loose cast made
'all' == 0evaluate totrue, so the check still passed by accident. PHP 8 reversed string-to-number comparison: the int is now cast to string instead, so'all' != 0and the check fails — every site after the first silentlycontinues past the save.Result: on a multisite network profile page, only the first row in the table actually persists. Every other site's change is dropped without any error.
Fix
Use a fresh local (
$valid_values) instead of mutating$options, and switch to strictin_array(..., true).Test plan
🤖 Generated with Claude Code