Make WordPress Core

Changeset 17643


Ignore:
Timestamp:
04/17/2011 08:35:51 AM (13 years ago)
Author:
westi
Message:

Introduce a special wp_die handler for XMLRPC requests to ensure we send an XML response.
Props koke for the original patch. See #16748.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r17642 r17643  
    28562856
    28572857/**
     2858 * Kill WordPress execution and display XML message with error message.
     2859 *
     2860 * This is the handler for wp_die when processing XMLRPC requests.
     2861 *
     2862 * @since 3.2.0
     2863 * @access private
     2864 *
     2865 * @param string $message Error message.
     2866 * @param string $title Error title.
     2867 * @param string|array $args Optional arguements to control behaviour.
     2868 */
     2869function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
     2870    global $wp_xmlrpc_server;
     2871    $defaults = array( 'response' => 500 );
     2872
     2873    $r = wp_parse_args($args, $defaults);
     2874
     2875    if ( $wp_xmlrpc_server ) {
     2876        $error = new IXR_Error( $r['response'] , $message);
     2877        $wp_xmlrpc_server->output( $error->getXml() );
     2878    }
     2879    die();
     2880}
     2881
     2882/**
     2883 * Filter to enable special wp_die handler for xmlrpc requests.
     2884 *
     2885 * @since 3.2.0
     2886 * @access private
     2887 */
     2888function _xmlrpc_wp_die_filter() {
     2889    return '_xmlrpc_wp_die_handler';
     2890}
     2891
     2892
     2893/**
    28582894 * Retrieve the WordPress home page URL.
    28592895 *
  • trunk/xmlrpc.php

    r17642 r17643  
    9999    logIO("I", $HTTP_RAW_POST_DATA);
    100100
     101// Make sure wp_die output is XML
     102add_filter( 'wp_die_handler', '_xmlrpc_wp_die_filter' );
     103
    101104// Allow for a plugin to insert a different class to handle requests.
    102105$wp_xmlrpc_server_class = apply_filters('wp_xmlrpc_server_class', 'wp_xmlrpc_server');
Note: See TracChangeset for help on using the changeset viewer.