Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.8

Request #8444 Handle PEAR_Errors returned from proxied object methods as errors
Submitted: 2006-08-15 10:36 UTC
From: koto at webworkers dot pl Assigned: auroraeosrose
Status: Closed Package: HTML_AJAX (version 0.4.1)
PHP Version: 5.1.0 OS: win
Roadmaps: 0.5.1    
Subscription  


 [2006-08-15 10:36 UTC] koto at webworkers dot pl (Krzysztof Kotowicz)
Description: ------------ Returning PEAR_Error object from proxied PHP object method returns message: PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in c:\php\PEAR\HTML\AJAX\JSON.php on line 241 (when using Xdebug extension - without it it would probably hang trying to convert the PEAR_Error object using the json serializer). I think as PEAR_Error class is solely used to represent various errors in PHP applications built upon PEAR packages that there should be an option in HTML_AJAX to represent this class as any other error. Appropriate working patch has already been submitted by Oliver Kuhl in mailing list: --- AJAX.php.orig 2006-04-27 07:14:00.000000000 +0200 +++ AJAX.php 2006-04-27 07:41:16.000000000 +0200 @@ -430,6 +430,16 @@ if(is_object($response) && is_a($response, 'HTML_AJAX_Response')) { $output = $response->getPayload(); $content = $response->getContentType(); + } elseif(is_a($response, 'PEAR_Error')) { + $serializer = $this->_getSerializer($this->serializer); + $output = $serializer->serialize(array( + 'message' => $response->getMessage(), + 'userinfo' => $response->getUserInfo(), + 'code' => $response->getCode(), + 'mode' => $response->getMode() + ) + ); + $content = $this->contentTypeMap['Error']; } else { $serializer = $this->_getSerializer($this->serializer); $output = $serializer->serialize($response); Test script: --------------- server.php ==== registerClass(new errortest,'errortest',array('geterror')); $server->handleRequest(); ?> index.php ======
<a href="#" onclick="remote.geterror(); return false;">show error</a> </body> </html> Expected result: ---------------- Error-handling takes place as it is for 'regular' PHP errors Actual result: -------------- After a few seconds processing the request, following message is displayed in result div: Fatal error: Maximum function nesting level of '100' reached, aborting! in c:\php\PEAR\HTML\AJAX\JSON.php on line 432 with the debug backtrace.

Comments

 [2006-10-25 18:01 UTC] auroraeosrose (emsmith)
fixed in svn