Skip to content

Make deprecated classes real aliases and add deprecation notices - #58

Open
pfefferle wants to merge 2 commits into
mainfrom
fix/real-backward-compat-aliases
Open

Make deprecated classes real aliases and add deprecation notices#58
pfefferle wants to merge 2 commits into
mainfrom
fix/real-backward-compat-aliases

Conversation

@pfefferle

@pfefferle pfefferle commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Problem

The 4.0.0 namespace refactoring left empty stub classes (class Webfinger {}) in includes/deprecated.php. Those make class_exists() checks pass, but any call to the old static API fatals — e.g. Webfinger::get_user_resource(), which third parties used, is an undefined method on the stub. This is the same class of breakage as indieweb/wordpress-indieauth#319, just masked by the stubs.

Solution

  • Webfinger_Admin and Webfinger_Legacy are now lazily aliased to Webfinger\Admin / Webfinger\Legacy via spl_autoload_register(), triggering _deprecated_class() on first use.
  • The global Webfinger class now extends Webfinger\Webfinger and restores get_user_resource() / get_user_resources() — which moved to Webfinger\User — as wrappers with _deprecated_function() notices.
  • The global Webfinger class itself stays eagerly defined and notice-free at class level: the ActivityPub plugin uses class_exists( 'Webfinger' ) as feature detection on every request, and a notice there would just spam debug logs.
  • The minimum required WordPress version is raised to 6.4, which _deprecated_class() requires (also added Requires at least to the plugin header, which only existed in the readme before).

Verification

  • New Test_Deprecated suite (TDD, watched fail first: stubs failed the alias assertions and errored on the moved methods). Full suite 54/54, phpcs clean.
  • End-to-end in wp-env with ActivityPub 7.7.1: /.well-known/webfinger serves a JRD including ActivityPub's aliases (ActivityPub correctly defers to the plugin via the class check); Webfinger::get_user_resource( 1 ) returns acct:admin@localhost, identical to Webfinger\User::get_resource( 1 ).
  • Deprecation notices verified live with WP_DEBUG on, and correctly silent with it off.

https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71

The empty stub classes made class_exists() checks pass but any call to
the old static methods fatal. Replace them:

- Webfinger_Admin and Webfinger_Legacy are lazily aliased to their
  namespaced replacements via spl_autoload_register(), triggering
  _deprecated_class() on first use.
- The global Webfinger class extends Webfinger\Webfinger and restores
  get_user_resource()/get_user_resources(), which moved to
  Webfinger\User, with _deprecated_function() notices.

The global Webfinger class stays eagerly defined and notice-free at
class level, because the ActivityPub plugin uses class_exists(
'Webfinger' ) for feature detection on every request.

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

This PR restores backward compatibility for pre-4.0.0 global class names after the namespace refactor by turning prior stub classes into real aliases/wrappers, adding appropriate deprecation notices, and updating the minimum required WordPress version to ensure _deprecated_class() support.

Changes:

  • Add a lazy aliasing layer for Webfinger_Admin / Webfinger_Legacy and reintroduce legacy static wrappers on the global Webfinger class with _deprecated_function() notices.
  • Add a PHPUnit suite to verify legacy aliases and deprecated wrappers behave correctly.
  • Raise the documented minimum required WordPress version to 6.4 (plugin header + readme) and update changelog notes.

Reviewed changes

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

File Description
webfinger.php Adds plugin header metadata for the new minimum WordPress version.
includes/deprecated.php Implements lazy aliasing for legacy class names and deprecated wrapper methods on the global Webfinger class.
tests/phpunit/includes/Test_Deprecated.php Adds test coverage for deprecated class aliases and deprecated wrapper methods.
readme.md Updates minimum required WordPress version and documents the deprecated-API compatibility changes in the changelog.

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

Comment thread includes/deprecated.php
Comment thread includes/deprecated.php
Comment thread includes/deprecated.php
Comment thread tests/phpunit/includes/Test_Deprecated.php
Comment thread readme.md
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.

2 participants