Make deprecated classes real aliases and add deprecation notices - #58
Open
pfefferle wants to merge 2 commits into
Open
Make deprecated classes real aliases and add deprecation notices#58pfefferle wants to merge 2 commits into
pfefferle wants to merge 2 commits into
Conversation
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
Contributor
There was a problem hiding this comment.
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_Legacyand reintroduce legacy static wrappers on the globalWebfingerclass 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The 4.0.0 namespace refactoring left empty stub classes (
class Webfinger {}) inincludes/deprecated.php. Those makeclass_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_AdminandWebfinger_Legacyare now lazily aliased toWebfinger\Admin/Webfinger\Legacyviaspl_autoload_register(), triggering_deprecated_class()on first use.Webfingerclass now extendsWebfinger\Webfingerand restoresget_user_resource()/get_user_resources()— which moved toWebfinger\User— as wrappers with_deprecated_function()notices.Webfingerclass itself stays eagerly defined and notice-free at class level: the ActivityPub plugin usesclass_exists( 'Webfinger' )as feature detection on every request, and a notice there would just spam debug logs._deprecated_class()requires (also addedRequires at leastto the plugin header, which only existed in the readme before).Verification
Test_Deprecatedsuite (TDD, watched fail first: stubs failed the alias assertions and errored on the moved methods). Full suite 54/54, phpcs clean./.well-known/webfingerserves a JRD including ActivityPub's aliases (ActivityPub correctly defers to the plugin via the class check);Webfinger::get_user_resource( 1 )returnsacct:admin@localhost, identical toWebfinger\User::get_resource( 1 ).WP_DEBUGon, and correctly silent with it off.https://claude.ai/code/session_0126gxnmr2SMc4X4J1Y6yf71