Hi All,

Attached is a patch that does the following:

- Allows *all* PHP Errors to be returned as a Valid XMLRPC Fault Packet (ie including 
parse errors).
- Allows the user to turn these errors on and off in php.ini
- Allows the user to set the faultCode (in the XMLRPC packet) via php.ini

Why is this important?

When using XMLRPC, anything at all that gets returned from the server needs to be a 
valid XMLRPC packet, either a Fault or a proper payload, if PHP dies with any sort of 
error or warning the XMLRPC client dies becasue it cant grok the returned payload.  
This limits PHP ever being used as an XMLRPC server.  With these patches the user can 
set the faultCode that gets returned to the client, so if im making an XMLRPC server 
that anyone can build a client that will access it I can make a statement like "If you 
get a faulCode of 666, then something broke on the server, bail out nicely and let me 
know".

I was originally thinking that maybe we should write a generice Errorhandler, ie let 
it be set in the php.ini, the reason for this is with more and more web services 
coming out (XMLRPC,SOAP, etc) each one will need a specific error format.  This might 
be something that could be discussed, but XMLRPC has been around the longest and alot 
of these other protocols are based on it, so here it is :)

I didnt change the php.ini-dist as I didnt know the protocol, ie, since most people 
wont want this feature do we leave it out?

Cheers,
Matta 
-- 
Matt Allen
Technical Director
Investigation Marketplace
0413 777 771
[EMAIL PROTECTED]
Index: main/main.c
===================================================================
RCS file: /repository/php4/main/main.c,v
retrieving revision 1.371
diff -r1.371 main.c
204a205,206
>       STD_PHP_INI_BOOLEAN("xmlrpc_errors",            "0",            
>PHP_INI_SYSTEM,                 OnUpdateBool,              xmlrpc_errors,             
>      php_core_globals,       core_globals)
>       STD_PHP_INI_ENTRY("xmlrpc_error_number",           NULL,        PHP_INI_ALL,   
>                 OnUpdateString,            xmlrpc_error_number,             
>php_core_globals,       core_globals)
397c399
<                       char *error_format;
---
>                       char error_format[1024];
399,401c401,411
<                       error_format = PG(html_errors) ?
<                               "<br>\n<b>%s</b>:  %s in <b>%s</b> on line 
<b>%d</b><br>\n"
<                               : "\n%s: %s in %s on line %d\n";
---
>             if (PG(html_errors)) {
>               strcpy(error_format , "<br>\n<b>%s</b>: %s in <b>%s</b> oni line 
><b>%d</b><br>\n");
>             } else if (PG(xmlrpc_errors)) {
>                               snprintf(error_format, 1023 , "<?xml
> 
>version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%d</int></value></member><member><name>faultString</name><value><string>%%s:%%s
> in %%s on line
> 
>%%d</string></value></member></struct></value></fault></methodResponse>",PG(xmlrpc_error_number));
>                         } else {
>                                 strcpy (error_format , "\n%s: %s in %s on line
> %d\n");
>                         }
Index: main/php_globals.h
===================================================================
RCS file: /repository/php4/main/php_globals.h,v
retrieving revision 1.63
diff -r1.63 php_globals.h
125a126,129
>       zend_bool xmlrpc_errors;
> 
>       short xmlrpc_error_number;
> 

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to