Skip to content

Detect IndieAuth via the INDIEAUTH_PLUGIN_VERSION constant - #327

Merged
pfefferle merged 1 commit into
trunkfrom
fix/indieauth-detection-via-constant
Jul 11, 2026
Merged

Detect IndieAuth via the INDIEAUTH_PLUGIN_VERSION constant#327
pfefferle merged 1 commit into
trunkfrom
fix/indieauth-detection-via-constant

Conversation

@pfefferle

@pfefferle pfefferle commented Jul 11, 2026

Copy link
Copy Markdown
Member

Problem

Micropub gates its whole initialization on an IndieAuth class check. That coupling to IndieAuth's internal class names broke once already, when IndieAuth 4.7.0 namespaced its classes and the class_exists( 'IndieAuth_Plugin' ) check silently disabled Micropub (indieweb/wordpress-indieauth#319). Trunk currently checks \IndieAuth\IndieAuth::class, which would break again on any future rename and triggers an autoload just for feature detection.

Solution

Check \defined( 'INDIEAUTH_PLUGIN_VERSION' ) instead. The constant exists since IndieAuth 4.7.0 — the same effective requirement as trunk's namespaced class check — is part of IndieAuth's stable public surface, and is cheaper than a class check (no autoloader involvement). It also enables version comparisons later if ever needed.

The test bootstrap now defines the constant instead of shipping a mock IndieAuth class.

Verification

  • TDD: switched the bootstrap to the constant first — 54 tests failed against the class-based gate (including the exact 404 vs 403 symptom from Errors return HTTP 201 status #319), then the gate change brought the suite back to baseline.
  • phpcs clean; full CI matrix (PHP 7.4/8.3/8.5) green.

https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71

A constant check does not depend on IndieAuth's internal class names,
which broke once before when IndieAuth 4.7.0 namespaced its classes
(indieweb/wordpress-indieauth#319), and avoids triggering an autoload.

The constant exists since IndieAuth 4.7.0, matching the namespaced
class check on trunk that already required 4.7.0.

The test bootstrap now defines the constant instead of mocking an
IndieAuth class.

Claude-Session: https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71
@pfefferle
pfefferle merged commit 74425b0 into trunk Jul 11, 2026
4 checks passed
@pfefferle pfefferle mentioned this pull request Jul 11, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant