[phpxmlrpc] Server.php in XML/RPC package: inability to switch off debugging - suggested modification

Pascal Van Hecke pascalvanhecke at yahoo.com
Mon Aug 11 15:10:32 BST 2003


(note: this was also posted to pear-dev mailinglist,
but got bounced on this one because of spam suspicion
- I sent it from another provider)

Hi,

In the Server.php file of the XML/RPC package
(contributed by Edd Dumbill and pearified by Stig
Bakken), there's no option to switch of the output of
an (outcommented) debug log in the resulting XML-RPC
response.

Because the XML_RPC_Server class only method is its
constructor, and this constructor does everything, the
only way to modify this was by adding an extra debug
parameter in the constructor.
Because the current signature is:

function XML_RPC_Server($dispMap, $serviceNow=1)

and I wanted to have backwards compatibility, I
changed the signature to

function XML_RPC_Server($dispMap, $option_array = 1)
and then checked the $option_array parameter for
"arrayness" :-).

A possible constructor could be now:

$DB_RPC_RemoteDataObjectServer = new XML_RPC_Server
				(
					array
					(
						"query" => array
							(
							"function"  =>
"DB_RPC_RemoteDataObjectServer_query",
							)
						//,
						//"other_function"=> array ("function" =>
"test_rpc_server") 
					),
					array
					(
						"debug" => 0
					)
				);


Part of the modified and attached Server.php file is
quoted hereunder (functions XML_RPC_Server and
serializeDebug have been changed)

Could this maybe be incorporated in PEAR CVS?

Regards,

pascal van hecke



Line 150-94 

class XML_RPC_Server
{
    var $dmap=array();
    var $debug;

    // function XML_RPC_Server($dispMap,
$serviceNow=1)//changed by pvh
    function XML_RPC_Server($dispMap, $option_array =
1)
    {
		global $HTTP_RAW_POST_DATA;
		// dispMap is a despatch array of methods
		// mapped to function names and signatures
		// if a method
		// doesn't appear in the map then an unknown
		// method error is generated
		$this->dmap=$dispMap;
		if (is_array($option_array))
		// second parameter carries associative array with
some initialisation
		{
			if (array_key_exists("debug", $option_array))
$this->debug = $option_array["debug"];
			if (array_key_exists("serviceNow", $option_array)) 
				$serviceNow = $option_array["serviceNow"];
			else 
				$serviceNow = 1;
		}
		else 
		// second parameter matches $servicenow param in old
signature
		{
			$serviceNow = $option_array;
		}
		
		if ($serviceNow) 
		{
	        $this->service();
		}
    }

    function serializeDebug()
    {
        global $XML_RPC_Server_debuginfo;
        if ($XML_RPC_Server_debuginfo!="" and
$this->debug) 
            return "<!-- DEBUG INFO:\n\n" .
                $XML_RPC_Server_debuginfo . "\n-->\n";
        else
            return "";
    }

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Server.php
Type: text/x-csv
Size: 12186 bytes
Desc: Server.php
Url : http://lists.usefulinc.com/pipermail/phpxmlrpc/attachments/20030811/b694f97e/Server.bin


More information about the phpxmlrpc mailing list