PHP Fatal error in serve_custom_response()
-
Hello!
I’m reporting a bug we encountered while reviewing our website logs:
[11-Mar-2026 15:27:46 UTC] PHP Fatal error: Uncaught TypeError: Yoast\WP\SEO\Schema_Aggregator\User_Interface\Site_Schema_Response_Header_Integration::serve_custom_response(): Return value must be of type bool, null returned in /home/customer/www/domain.example/public_html/wp-content/plugins/wordpress-seo/src/schema-aggregator/user-interface/site-schema-response-header-integration.php:62It seems that in the following function:
public function serve_custom_response( $served, $result, $request ): bool {
if ( \strpos( $request->get_route(), '/yoast/v1/schema-aggregator' ) !== 0 ) {
return $served;
}
if ( ! $result instanceof WP_REST_Response || $result->is_error() ) {
return $served;
}
$this->schema_map_header_adapter->set_header_for_request( $result );
return true;
}The function is expected to return a boolean, but
$servedcan benull, which causes the fatal error when it is returned.As a temporary fix, we changed the return to:
return $served ?? false;This resolves the issue on our side.
Best regards,
Miguel
You must be logged in to reply to this topic.