[wp-trac] [WordPress Trac] #63652: _oembed_rest_pre_serve_request() can erroneously return a string value
WordPress Trac
noreply at wordpress.org
Tue Jul 1 19:28:51 UTC 2025
#63652: _oembed_rest_pre_serve_request() can erroneously return a string value
----------------------------+----------------------------------------
Reporter: SergeyBiryukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.9
Component: Embeds | Version: 4.4
Severity: normal | Keywords: needs-patch good-first-bug
Focuses: |
----------------------------+----------------------------------------
`_oembed_rest_pre_serve_request()` is attached to the
`rest_pre_serve_request` filter and is supposed to return a boolean value.
However, there is a code path where it returns a string via
`get_status_header_desc()`, see the second conditional:
{{{
// Embed links inside the request.
$data = $server->response_to_data( $result, false );
if ( ! class_exists( 'SimpleXMLElement' ) ) {
status_header( 501 );
die( get_status_header_desc( 501 ) );
}
$result = _oembed_create_xml( $data );
// Bail if there's no XML.
if ( ! $result ) {
status_header( 501 );
return get_status_header_desc( 501 );
}
}}}
Since the function is expected to output a string, I think `return` should
be replaced with `die` here, to match the first conditional.
Introduced in [35436] / #34207.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63652>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list