Skip to content

06: Conflict policy constants - #6

Open
nikolaystrikhar wants to merge 3 commits into
05-ci-static-analysisfrom
06-conflict-policy
Open

06: Conflict policy constants#6
nikolaystrikhar wants to merge 3 commits into
05-ci-static-analysisfrom
06-conflict-policy

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: the three conflict-policy string constants, plus all() and is_valid().

Stacked on #5.

Usage:

"conflict_policy" => Conflict_Policy::DEACTIVATE,  // or DEFER, or NOTICE_ONLY

Why this way: string constants rather than an enum because the PHP floor is 7.4, and rather than bare strings because a host may persist one in an option. The test asserts the literal values for that reason — they are a public contract, not an implementation detail.

The review added the two helpers, and they are the substantive change here. The plan had nothing validating a policy: Sub_Plugin::get_conflict_policy() returns whatever the config or the …/conflict_policy filter hands back, and the resolver switches on that string with default: falling into deactivate(). So "defered" — a typo, or a stale return from someone else's filter — would deactivate a plugin the site owner deliberately turned on. Of the three branches that is the destructive one and the least recoverable, and it was the one reached by accident. is_valid() lets the resolver treat unknown as its own case; the plan is updated so it does, falling back to NOTICE_ONLY.

The constant set is now pinned by reflection rather than by a distinctness check that the literal-value test already implied. That catches an added fourth policy, which would otherwise be swallowed silently by the same default: branch.

Also corrected the DEACTIVATE description in both the README and the docblock. It read "deactivate the standalone, load the bundled copy, notify, redirect", but the bundled copy does not load on that request — the standalone has already defined the guard constant before plugins_loaded fires, so the load path skips it, and the request ends at the redirect anyway. It loads on the next request. The old wording had the causality backwards.

Verify: slic run unit — 29 tests, 40 assertions, green. composer test:analysis[OK] No errors, exit 0.

Nothing validated a policy string. The resolver switches on it with a
default branch that deactivates, so a typo or a stale filter return would
turn off a plugin the site owner deliberately activated -- the most
surprising of the three outcomes to arrive at by accident. all() and
is_valid() give callers a way to tell unknown from DEACTIVATE.

Also pin the constant set by reflection, so a fourth policy cannot be added
without the resolver's switch being revisited, and correct the DEACTIVATE
description: the bundled copy loads on the next request, not this one, since
the standalone has already defined the guard constant and the request ends
at the redirect.
@nikolaystrikhar nikolaystrikhar mentioned this pull request Aug 3, 2026
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