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_dispatch priority 10 and returns WP_Error
ACF trigger initialize method, 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 $response to null
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 )
meanwhile the core filter expects a "possible" return value:
Sample Case:
rest_pre_dispatch
priority 10 and returnsWP_Error
initialize
method, since this method basically always returns null, the previous filter WP_Error would be useless$response
to null