Normalize fixes REST API namespace - #1841
Conversation
📝 WalkthroughWalkthroughFixes REST routes now support the canonical ChangesFixes REST namespace
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request migrates the REST API namespace for fixes from "edac/v1" to "accessibility-checker/v1" across admin scripts, frontend scripts, and React components, while retaining the legacy namespace for backward compatibility. It also introduces corresponding Jest and PHPUnit tests. The review feedback highlights a critical issue where the registered callback get_fixes is not defined in FixesManager, which would cause a fatal error. Additionally, it suggests a more reliable way to initialize the REST server in PHPUnit tests to avoid potential issues with do_action( 'rest_api_init' ).
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| $routes = [ | ||
| '/fixes' => [ | ||
| 'methods' => 'GET', | ||
| 'callback' => [ $this, 'get_fixes' ], |
There was a problem hiding this comment.
The callback [ $this, 'get_fixes' ] is registered for the /fixes route, but the get_fixes method is not defined anywhere in the FixesManager class. This will result in a fatal error (Uncaught Error: Call to undefined method ...) when a GET request is made to the /fixes endpoint. Please implement the get_fixes method or map it to an existing method (such as returning get_fixes_settings()).
| do_action( 'rest_api_init' ); | ||
|
|
||
| $registered_routes = rest_get_server()->get_routes(); |
There was a problem hiding this comment.
Calling do_action( 'rest_api_init' ) before rest_get_server() is initialized can be problematic. In WordPress, if the global $wp_rest_server is not yet instantiated, register_rest_route() calls will return false and do nothing. When rest_get_server() is subsequently called, it will initialize the server and trigger rest_api_init again. To ensure a clean and reliable test environment, initialize the REST server first using rest_get_server() and let it handle the action firing.
$server = rest_get_server();
$registered_routes = $server->get_routes();ca917f6 to
a4f87e8
Compare
Summary
Testing
Fixes #1736
Checklist