XML-RPC: Emit an appropriate HTTP status code when an error is returned in response to an XML-RPC request.

This most notably affects the response when XML-RPC is disabled or when the supplied username and password is incorrect.

Props ericmann

Fixes #48213

Built from https://develop.svn.wordpress.org/trunk@49862


git-svn-id: http://core.svn.wordpress.org/trunk@49581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2020-12-21 20:23:02 +00:00
parent b8e5751dd1
commit ec80a9fd63
3 changed files with 8 additions and 3 deletions

View File

@ -129,6 +129,11 @@ EOD;
if ($message && !is_object($error)) {
$error = new IXR_Error($error, $message);
}
if ( function_exists( 'status_header' ) ) {
status_header( $error->code );
}
$this->output($error->getXml());
}

View File

@ -286,8 +286,8 @@ class wp_xmlrpc_server extends IXR_Server {
*
* @since 3.5.0
*
* @param string $error The XML-RPC error message.
* @param WP_Error $user WP_Error object.
* @param IXR_Error $error The XML-RPC error message.
* @param WP_Error $user WP_Error object.
*/
$this->error = apply_filters( 'xmlrpc_login_error', $this->error, $user );
return false;

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7-alpha-49860';
$wp_version = '5.7-alpha-49862';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.