WordPress.org

Make WordPress Core

Ticket #10658: XMLRPCErrorString.diff

File XMLRPCErrorString.diff, 1.8 KB (added by redsweater, 6 years ago)
  • xmlrpc.php

     
    207207                $this->IXR_Server($this->methods); 
    208208        } 
    209209 
     210        function errorStringForDisabledXMLRPC() { 
     211                return sprintf(__( 'XML-RPC services are disabled on this blog.  An admin user can enable them at %s'),  admin_url('options-writing.php')); 
     212        } 
     213 
     214        function serve($data = false) { 
     215                // We want to intercept the case where a GET request is issued, but XMLRPC support is disabled. 
     216                // In this case, it makes a more useful failure message (and one that matches wp-app.php) if we 
     217                // express the disabled error string instead of allowing the default 'POST requests only' error in IXR.  
     218                global $HTTP_RAW_POST_DATA; 
     219                if ( !get_option( 'enable_xmlrpc' ) && !$HTTP_RAW_POST_DATA) { 
     220                        header( 'Content-Type: text/plain' ); 
     221                        die($this->errorStringForDisabledXMLRPC()); 
     222                } 
     223                else { 
     224                        parent::serve($data); 
     225                } 
     226        } 
     227 
    210228        /** 
    211229         * Test XMLRPC API by saying, "Hello!" to client. 
    212230         * 
     
    246264         */ 
    247265        function login_pass_ok($user_login, $user_pass) { 
    248266                if ( !get_option( 'enable_xmlrpc' ) ) { 
    249                         $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog.  An admin user can enable them at %s'),  admin_url('options-writing.php') ) ); 
     267                        $this->error = new IXR_Error( 405, $this->errorStringForDisabledXMLRPC()); 
    250268                        return false; 
    251269                } 
    252270 
     
    268286         */ 
    269287        function login($username, $password) { 
    270288                if ( !get_option( 'enable_xmlrpc' ) ) { 
    271                         $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog.  An admin user can enable them at %s'),  admin_url('options-writing.php') ) ); 
     289                        $this->error = new IXR_Error( 405, $this->errorStringForDisabledXMLRPC()); 
    272290                        return false; 
    273291                } 
    274292