AdvancedCustomFields / AdvancedCustomFields/acf
rest_pre_dispatch conflicts
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
This function is hooked into rest_pre_dispatch: https://github.com/AdvancedCustomFields/acf/blob/fd6fbd054972ea4d54d3edc92fe66cf2b713d0ec/includes/rest-api/class-acf-rest-api.php#L26-L44
This method basically void method ( in the end it will always returns null )
the filter priority is 10 ( which is default, and higher chance to possibly conflict with other plugins that utilize this filter )
add_filter( 'rest_pre_dispatch', array( $this, 'initialize' ), 10, 3 );
meanwhile the core filter expects a "possible" return value:
/**
* Filters the pre-calculated result of a REST API dispatch request.
*
* Allow hijacking the request before dispatching by returning a non-empty. The returned value
* will be used to serve the request instead.
*
* @since 4.4.0
*
* @param mixed $result Response to replace the requested version with. Can be anything
* a normal endpoint can return, or null to not hijack the request.
* @param WP_REST_Server $server Server instance.
* @param WP_REST_Request $request Request used to generate the response.
*/
$result = apply_filters( 'rest_pre_dispatch', null, $this, $request );
Sample Case:
- Plugin A utilize
rest_pre_dispatchpriority 10 and returnsWP_Error - ACF trigger
initializemethod, since this method basically always returns null, the previous filter WP_Error would be useless - That makes plugin A broken, and it should not Plugin A responsibility to make it work with ACF.
- It is ACF issue that always override
$responseto null
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in includes/rest-api/class-acf-rest-api.php at the rest_pre_dispatch hook and initialize method, then compare its behavior with WordPress's rest_pre_dispatch contract shown in the issue. Trace how prior filter results are passed through and identify the existing REST API tests covering dispatch responses. Done means another plugin's non-null response, including WP_Error, is not discarded by ACF.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100