Skip to content

Fix: save_profile_settings drops every site after the first on PHP 8#72

Open
svandragt wants to merge 1 commit into
masterfrom
follow-unfollow/fix-php8-profile-save
Open

Fix: save_profile_settings drops every site after the first on PHP 8#72
svandragt wants to merge 1 commit into
masterfrom
follow-unfollow/fix-php8-profile-save

Conversation

@svandragt
Copy link
Copy Markdown

@svandragt svandragt commented May 14, 2026

Summary

Falcon_Connector::save_profile_settings() shadow-mutated the outer foreach's $options to a numeric-indexed array. On the second and subsequent sites in the network profile-page save, the validity check became in_array($value, [0, 1]).

On PHP 7 the string→int loose cast made 'all' == 0 evaluate to true, so the check still passed by accident. PHP 8 reversed string-to-number comparison: the int is now cast to string instead, so 'all' != 0 and the check fails — every site after the first silently continues 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 strict in_array(..., true).

Test plan

  • On PHP 8.3, save changes for two sites in one POST — both persist.
  • Verify on PHP 7.4 (if still supported) — still passes; the strict comparison only tightens.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant