Server.php in XML/RPC package: inability to switch off debugging - suggested modification
| From: | Yahoo) | Date: | Thu, 17 Jul 2003 14:34:16 +0000 |
| Subject: | Server.php in XML/RPC package: inability to switch off debugging - suggested modification | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-18338@lists.php.net to get a copy of this message | ||
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 "";
}
Attachment: [a/octet-stream] Server.php
Attachment: [a/octet-stream] Server.php