- xmlrpcs.inc: add a new member var in server class to allow fine-tuning of the encod...
[plcapi.git] / lib / xmlrpcs.inc
index f124a01..ea6ec13 100644 (file)
 \r
        class xmlrpc_server\r
        {\r
-               /// array defining php functions exposed as xmlrpc methods by this server\r
+               /**\r
+               * Array defining php functions exposed as xmlrpc methods by this server\r
+               * @access private\r
+               */\r
                var $dmap=array();\r
                /**\r
                * Defines how functions in dmap will be invoked: either using an xmlrpc msg object\r
                * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals'\r
                */\r
                var $functions_parameters_type='xmlrpcvals';\r
+           /**\r
+           * Option used for fine-tuning the encoding the php values returned from\r
+           * functions registered in the dispatch map when the functions_parameters_types\r
+           *  member is set to 'phpvals'\r
+           * @see php_xmlrpc_encode for a list of values\r
+           */\r
+           var $phpvals_encoding_options = array( 'auto_dates' );\r
                /// controls wether the server is going to echo debugging messages back to the client as comments in response body. valid values: 0,1,2,3\r
                var $debug = 1;\r
                /**\r
                * NB: pretty dangerous if you accept every charset and do not have mbstring enabled)\r
                */\r
                var $response_charset_encoding = '';\r
-               /// storage for internal debug info\r
+               /**\r
+               * Storage for internal debug info\r
+               * @access private\r
+               */\r
                var $debug_info = '';\r
-               /// extra data passed at runtime to method handling functions. Used only by EPI layer\r
+               /**\r
+               * Extra data passed at runtime to method handling functions. Used only by EPI layer\r
+               */\r
                var $user_data = null;\r
 \r
                /**\r
                        else\r
                        {\r
                                xml_parser_free($parser);\r
-                               if ($this->functions_parameters_type != 'xmlrpcvals')\r
+                           // small layering violation in favor of speed and memory usage:\r
+                           // we should allow the 'execute' method handle this, but in the\r
+                           // most common scenario (xmlrpcvals type server with some methods\r
+                           // registered as phpvals) that would mean a useless encode+decode pass\r
+                               if ($this->functions_parameters_type != 'xmlrpcvals' || (isset($this->dmap[$GLOBALS['_xh']['method']]['parameters_type']) && ($this->dmap[$GLOBALS['_xh']['method']]['parameters_type'] == 'phpvals')))\r
                                {\r
                                        if($this->debug > 1)\r
                                        {\r
                        {\r
                                $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler');\r
                        }\r
+                   // Allow mixed-convention servers\r
                        if (is_object($m))\r
                        {\r
                                if($sysCall)\r
                                {\r
                                        // what should we assume here about automatic encoding of datetimes\r
                                        // and php classes instances???\r
-                                       $r = new xmlrpcresp(php_xmlrpc_encode($r, array('auto_dates')));\r
+                                       $r = new xmlrpcresp(php_xmlrpc_encode($r, $this->phpvals_encoding_options));\r
                                }\r
                        }\r
                        if($this->debug > 2)\r