Skip to content

07: Sub_Plugin - #7

Open
nikolaystrikhar wants to merge 4 commits into
06-conflict-policyfrom
07-sub-plugin
Open

07: Sub_Plugin#7
nikolaystrikhar wants to merge 4 commits into
06-conflict-policyfrom
07-sub-plugin

Conversation

@nikolaystrikhar

@nikolaystrikhar nikolaystrikhar commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Sub_Plugin holds one registered sub-plugin, its configuration, and every per-sub-plugin decision. Each predicate is a plain method taking no hooks, so later collaborators stay thin and each decision is testable directly.

Stacked on #6.

  • is_callable() was the type discriminator on conflict_policy, enabled and both message keys. A stored policy string like date or flush was invoked rather than used — an uncaught TypeError at plugins_loaded on PHP 8, a silent empty policy on 7.4. Strings and bools are values now.
  • An uncallable dependency_check reported dependencies met, so a typo'd function name or a private method silently dropped the guard. Both callable-only keys are validated at registration.
  • Required keys were checked with empty() but never type-checked. An array casts to "Array", collapsing every affected sub-plugin onto one registry key. They must be non-empty strings now.
  • The network check was dead codeis_plugin_active() already ORs in is_plugin_active_for_network(), and the test defending it stubbed a state WordPress cannot produce.
  • get_conflict_notice_message() had no fallback, so a host that configured no message got WordPress's raw fatal error screen. It takes a $default.

Verify: slic run unit — 77 tests, 111 assertions. composer test:analysis[OK] No errors.

This was referenced Aug 3, 2026
- is_callable() was the type discriminator on every string-or-callable key,
  and it is true for any string naming an existing function. conflict_policy
  is designed to be readable from an option, so a stored 'date' or 'flush'
  was invoked instead of used: a TypeError at plugins_loaded on PHP 8, a
  silent empty policy on 7.4. Strings and bools are values now.
- Type-check required keys. An array passed the truthiness check and cast to
  "Array", which every sub-plugin making that mistake would have shared as
  its registry key, activation key, and notice id.
- Reject an uncallable dependency_check or activation_callback at
  registration. Read-time is_callable() made "not configured" and
  "configured but uncallable" indistinguishable, so a dependency_check
  pointing at a private method reported dependencies met and let the load
  run into the fatal it guards.
- Drop the redundant network check: WordPress's is_plugin_active() already
  ORs it in. The test that pinned it described a state WordPress cannot
  produce.
- Guard the plugin.php require on is_plugin_active_for_network, since
  is_plugin_active is a function third parties shim.
- Give get_conflict_notice_message() a default, guard the filter result with
  is_scalar(), and pass the Sub_Plugin to every configured callable.
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