Skip to content
This repository was archived by the owner on Nov 2, 2026. It is now read-only.

Optional analytics ability lookups never emit _doing_it_wrong when extrachill-analytics is absent - #443

Merged
chubes4 merged 1 commit into
mainfrom
fix/issue-442-extrachill-users
Sep 27, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/issue-442-extrachill-users

Conversation

@chubes4

@chubes4 chubes4 commented Sep 27, 2026

Copy link
Copy Markdown
Member

Summary

Guards every optional-dependency lookup of the `extrachill/track-analytics-event` ability so unregistered-ability calls no longer trigger WordPress 6.9+'s `_doing_it_wrong()` notice, which was breaking `WP_UnitTestCase` suites (12 failures in extrachill-events) whenever the optional extrachill-analytics plugin wasn't loaded. Closes #442.

What changed

  • inc/core/abilities/create-user.php:299 — `wp_get_ability()` is now only called when `function_exists('wp_has_ability') && wp_has_ability('extrachill/track-analytics-event')` is true; otherwise `$analytics_ability` is set to `null`, preserving the existing `if ( $analytics_ability )` fallback exactly.
  • inc/team-experience/events.php:85 — replaced the `function_exists('wp_get_ability')` presence check with a `wp_has_ability()` registration check before calling `wp_get_ability()`, keeping the existing no-op-returns-0 contract.
  • inc/onboarding/form-handler.php:130 — replaced the bare `function_exists('wp_get_ability') ? wp_get_ability(...) : null` ternary with a `wp_has_ability()`-gated version.
  • inc/onboarding/analytics.php:19 and :66 — both `ec_users_emit_onboarding_event()` and `ec_users_emit_onboarding_artist_access_granted()` now gate `wp_get_ability()` on `wp_has_ability()` the same way.
  • No new shared helper file was introduced (kept the diff scoped strictly to the 5 listed call sites); each site inlines the identical, small guard expression.
  • Added `tests/integration/UserCreationTest.php::test_create_user_succeeds_without_analytics_ability_registered`, which reflection-captures the live analytics ability's registration args, unregisters it, exercises `extrachill/create-user` end-to-end, asserts success with no unexpected incorrect-usage notice, then restores the original ability registration in a `finally` block to avoid cross-test pollution.

How to test

  1. Run php -l inc/core/abilities/create-user.php; expect passes as recorded by Cook's deterministic gate.

Compatibility

[operator-only reference omitted]

Evidence

AI assistance

  • AI assistance: Yes
  • Tool(s): Homeboy (opencode)
  • Model: anthropic/claude-sonnet-5
  • Used for: [operator-only reference omitted]

@chubes4 chubes4 closed this Sep 27, 2026
@chubes4
chubes4 merged commit 510234b into main Sep 27, 2026
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create-user calls wp_get_ability() for optional analytics ability without wp_has_ability() guard (_doing_it_wrong notice)

1 participant