Skip to content

Restore pre-4.7.0 global class names as backward-compat aliases#320

Merged
pfefferle merged 8 commits into
trunkfrom
fix/319-backward-compat-class-aliases
Jul 13, 2026
Merged

Restore pre-4.7.0 global class names as backward-compat aliases#320
pfefferle merged 8 commits into
trunkfrom
fix/319-backward-compat-class-aliases

Conversation

@pfefferle

@pfefferle pfefferle commented Jul 11, 2026

Copy link
Copy Markdown
Member

Problem

The 4.7.0 namespace refactoring (#306) removed all global classes without backward-compat aliases. Third-party plugins that check for the old names broke — most notably Micropub, which gates its whole initialization on class_exists( 'IndieAuth_Plugin' ) and therefore never registers its REST routes under 4.7.0 (rest_no_route 404).

Fixes #319

Solution

New includes/compat.php registers the old global class names as aliases of their namespaced replacements:

  • IndieAuth_Plugin is aliased eagerly and notice-free, so class_exists( 'IndieAuth_Plugin', false ) checks work and feature detection doesn't spam debug logs.
  • The remaining 20 classes are aliased lazily via spl_autoload_register(); first use triggers _deprecated_class() (guarded by function_exists(), since the plugin supports WP 6.2 and _deprecated_class() needs 6.4) pointing to the namespaced replacement.
  • Eight pre-4.7.0 classes are intentionally not aliased: the abstract IndieAuth_Endpoint, whose functionality moved to the IndieAuth\Rest\Token_Management trait (a class alias cannot represent a trait), and the seven *_Endpoint classes (authorization, introspection, metadata, revocation, ticket, token, userinfo), whose legacy get_endpoint() API was static while the replacement controller methods are not — an alias would not restore the old calling convention.

Verification

  • New Test_Compat suite asserts every legacy name resolves to its namespaced replacement, that lazy aliases trigger the expected deprecation, and that the excluded endpoint classes stay unaliased (30 tests, written first and watched fail).
  • Full suite passes (97 tests, 247 assertions); phpcs clean.
  • Reproduced IndieAuth 4.7.0 breaks Micropub's REST endpoint registration (rest_no_route 404) #319 end-to-end in wp-env with Micropub 2.5.1: stock 4.7.0 → GET /?rest_route=/micropub/1.0/endpoint returns 404 rest_no_route; with this patch → 403 (route registered, auth required), matching 4.6.0 behavior. Eager/lazy alias semantics, IndieAuth_Client_Taxonomy::get_client() callability and Token_User instantiation verified at runtime via wp eval.

Companion change for WebFinger: pfefferle/wordpress-webfinger#58

The 4.7.0 namespace refactoring removed all global classes, which broke
third-party plugins that check for them — most notably Micropub, which
gates its whole initialization (including its REST route registration)
on class_exists( 'IndieAuth_Plugin' ).

Register the old names as aliases of their namespaced replacements:
IndieAuth_Plugin eagerly, so checks with autoloading disabled also
work, and the rest lazily via spl_autoload_register.

Fixes #319

Claude-Session: https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71
@pfefferle pfefferle requested a review from Copilot July 11, 2026 12:21
@pfefferle pfefferle requested a review from a team July 11, 2026 12:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores backward compatibility for pre-4.7.0 global class names by introducing a compatibility layer that aliases legacy class names to their new namespaced equivalents, unblocking third-party plugins (notably Micropub) that detect IndieAuth via class_exists( 'IndieAuth_Plugin' ).

Changes:

  • Add includes/compat.php to register legacy-to-namespaced class aliases (with IndieAuth_Plugin intended to be available eagerly).
  • Load the compatibility layer during plugin bootstrap.
  • Add PHPUnit coverage asserting legacy class names resolve correctly, and document the change in the changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
includes/compat.php Defines the legacy→namespaced class map and registers aliasing via an autoloader + eager alias for IndieAuth_Plugin.
indieauth.php Loads the new compat layer during plugin startup.
tests/phpunit/tests/includes/class-test-compat.php Adds tests to validate legacy class alias behavior and Micropub detection expectations.
readme.md Adds a changelog entry describing the restored legacy class aliases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/compat.php Outdated
Comment thread tests/phpunit/tests/includes/class-test-compat.php
Comment thread readme.md
Lazily aliased legacy classes now trigger _deprecated_class() on first
use. IndieAuth_Plugin stays eagerly aliased and notice-free, because
plugins like Micropub use it for feature detection.

_deprecated_class() requires WordPress 6.4, so the minimum required
version is raised from 6.2 to 6.4.

Claude-Session: https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71
The WP 6.4 requirement bump was meant for the WebFinger plugin, not
for IndieAuth.

Claude-Session: https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71
ClassicPress does not have _deprecated_class(), so the compat
autoloader's function_exists() guard correctly skips the notice there.
Mirror that condition in the test instead of expecting the notice
unconditionally, which failed the ClassicPress CI matrix.

Claude-Session: https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71
Guard the eager IndieAuth_Plugin alias against the name being already
defined (e.g. by a site-level workaround for the 4.7.0 breakage). The
lazy autoloader path needs no guard, because PHP never invokes
autoloaders for defined classes.

Add an assertion that COMPAT_CLASS_MAP and the test data provider
cover the same classes, while keeping the provider as an independent
pin of the pre-4.7.0 surface.

Claude-Session: https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread includes/compat.php
Comment thread includes/compat.php

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@pfefferle pfefferle merged commit f99ea78 into trunk Jul 13, 2026
10 checks passed
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.

IndieAuth 4.7.0 breaks Micropub's REST endpoint registration (rest_no_route 404)

2 participants