- xmlrpc.inc: add support for the <ex:nil/> from the apache library, both in input...
authorggiunta <ggiunta@013ecfd8-0664-425d-a759-9c98391dc3f9>
Thu, 16 Jul 2009 22:33:31 +0000 (22:33 +0000)
committerggiunta <ggiunta@013ecfd8-0664-425d-a759-9c98391dc3f9>
Thu, 16 Jul 2009 22:33:31 +0000 (22:33 +0000)
- xmlrpc.inc, testsuite.php: remove usage of split(), deprecated in php 5.3
- testsuite.php: flush better results with output_buffering on
- server: php: avoid one warning about static function calls

git-svn-id: https://svn.code.sf.net/p/phpxmlrpc/code/trunk/xmlrpc@23 013ecfd8-0664-425d-a759-9c98391dc3f9

ChangeLog
demo/server/server.php
lib/xmlrpc.inc
test/PHPUnit/TestSuite.php
test/testsuite.php

index da7d5f5..b7227b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-07-16 - G. Giunta (giunta.gaetano@gmail.com) thanks Jean-Jacques Sarton\r
+\r
+       * xmlrpc.inc: add support for the <ex:nil/> from the apache library, both\r
+       in input and output\r
+\r
+       * xmlrpc.inc, testsuite.php: remove usage of split(), deprecated in php 5.3\r
+\r
+       * testsuite.php: flush better results with output_buffering on\r
+\r
+       * server: php: avoid one warning about static function calls\r
+\r
 2009-07-02 - G. Giunta (giunta.gaetano@gmail.com) thanks Heiko Stuebner\r
 \r
        * xmlrpc.inc: fix: when checking the parameters against the signatures xmlrpc\r
@@ -12,7 +23,7 @@
 \r
        * create php4 branch, rename trunk to 3.0.0beta - it will be the php5-only version\r
 \r
-       * xmlrpc.inc: removed test fpr php version and inclusion of compat patches for really\r
+       * xmlrpc.inc: removed test for php version and inclusion of compat patches for really\r
        really old versions of php 4\r
 \r
 2009-03-16 - G. Giunta (giunta.gaetano@gmail.com) thanks Tommaso Trani\r
index 2a8d185..3a42ad3 100644 (file)
@@ -36,14 +36,14 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource']))
                        return new xmlrpcresp(new xmlrpcval(1, 'boolean'));
                }
 
-        /**
-        * a PHP version of the state-number server. Send me an integer and i'll sell you a state
-        * @param integer $s
-        * @return string
-        * */
-               function findstate($s)
-        {
-                   return inner_findstate($s);
+               /**
+               * a PHP version of the state-number server. Send me an integer and i'll sell you a state
+               * @param integer $s
+               * @return string
+               * */
+               static function findstate($s)
+               {
+                       return inner_findstate($s);
                }
        }
 
@@ -129,7 +129,7 @@ in an alphabetic order.';
 
        $findstate3_sig = wrap_php_function(array('xmlrpc_server_methods_container', 'findstate'));
 
-    $obj = new xmlrpc_server_methods_container();
+       $obj = new xmlrpc_server_methods_container();
 
        $findstate4_sig = wrap_php_function(array($obj, 'findstate'));
 
@@ -241,7 +241,7 @@ in an alphabetic order.';
        $agesorter_doc='Send this method an array of [string, int] structs, eg:
 <pre>
  Dave   35
- Edd    45
+ Edd   45
  Fred   23
  Barney 37
 </pre>
@@ -570,9 +570,9 @@ mimetype, a string, is a standard MIME type, for example, text/plain.
                return new xmlrpcresp(new xmlrpcval(array(
                        "ctLeftAngleBrackets"  => new xmlrpcval($lt, "int"),
                        "ctRightAngleBrackets" => new xmlrpcval($gt, "int"),
-                       "ctAmpersands"         => new xmlrpcval($amp, "int"),
-                       "ctApostrophes"        => new xmlrpcval($ap, "int"),
-                       "ctQuotes"             => new xmlrpcval($qu, "int")),
+                       "ctAmpersands"           => new xmlrpcval($amp, "int"),
+                       "ctApostrophes"         => new xmlrpcval($ap, "int"),
+                       "ctQuotes"                       => new xmlrpcval($qu, "int")),
                        "struct"
                ));
        }
index b02eae2..a4c9ef2 100644 (file)
@@ -89,7 +89,8 @@
                'METHODNAME' => array('METHODCALL'),\r
                'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),\r
                'FAULT' => array('METHODRESPONSE'),\r
-               'NIL' => array('VALUE') // only used when extension activated\r
+               'NIL' => array('VALUE'), // only used when extension activated\r
+               'EX:NIL' => array('VALUE') // only used when extension activated\r
        );\r
 \r
        // define extra types for supporting NULL (useful for json or <NIL/>)\r
        /// @deprecated\r
        $GLOBALS['xmlrpc_backslash']=chr(92).chr(92);\r
 \r
-       // set to TRUE to enable correct decoding of <NIL/> values\r
+       // set to TRUE to enable correct decoding of <NIL/> and <EX:NIL/> values\r
        $GLOBALS['xmlrpc_null_extension']=false;\r
 \r
+       // set to TRUE to enable encoding of php NULL values to <EX:NIL/> instead of <NIL/>\r
+       $GLOBALS['xmlrpc_null_apache_encoding']=false;\r
+\r
        // used to store state during parsing\r
        // quick explanation of components:\r
        //   ac - used to accumulate values\r
                                        $GLOBALS['_xh']['vt']=null;\r
                                        break;\r
                                case 'NIL':\r
+                               case 'EX:NIL':\r
                                        if ($GLOBALS['xmlrpc_null_extension'])\r
                                        {\r
                                                if ($GLOBALS['_xh']['vt']!='value')\r
                                        $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']);\r
                                        break;\r
                                case 'NIL':\r
+                               case 'EX:NIL':\r
                                        if ($GLOBALS['xmlrpc_null_extension'])\r
                                        {\r
                                                $GLOBALS['_xh']['vt']='null';\r
@@ -2289,7 +2295,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
                                        }\r
                                }\r
                                // be tolerant to line endings, and extra empty lines\r
-                               $ar = split("\r?\n", trim(substr($data, 0, $pos)));\r
+                               $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));\r
                                while(list(,$line) = @each($ar))\r
                                {\r
                                        // take care of multi-line headers and cookies\r
@@ -2922,7 +2928,14 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
                                                $rs.="<${typ}>".preg_replace('/\\.?0+$/','',number_format((double)$val, 128, '.', ''))."</${typ}>";\r
                                                        break;\r
                                                case $GLOBALS['xmlrpcNull']:\r
-                                                       $rs.="<nil/>";\r
+                                                   if ($GLOBALS['xmlrpc_null_apache_encoding'])\r
+                                                   {\r
+                                                       $rs.="<ex:nil/>";\r
+                                                   }\r
+                                                   else\r
+                            {\r
+                                $rs.="<nil/>";\r
+                            }\r
                                                        break;\r
                                                default:\r
                                                        // no standard type value should arrive here, but provide a possibility\r
@@ -3399,7 +3412,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
                                {\r
                                        $xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);\r
                                }\r
-                               if (in_array('null_extension', $options))\r
+                               else if (in_array('null_extension', $options))\r
                                {\r
                                        $xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);\r
                                }\r
index f0618d0..629b3fc 100644 (file)
@@ -157,7 +157,7 @@ class PHPUnit_TestSuite {
         for ($i = 0; $i < sizeof($this->_tests) && !$result->shouldStop(); $i++) {
             $this->_tests[$i]->run($result);
             if ($show_progress != '') {
-                echo $show_progress; flush();
+                echo $show_progress; flush(); ob_flush();
             }
         }
     }
index 93de1bd..5784be4 100644 (file)
@@ -14,6 +14,7 @@
        if ((int)ini_get('max_execution_time') < 180)
                ini_set('max_execution_time', 180);
 
+       ini_set('max_execution_time', 180);
 
        $suite = new PHPUnit_TestSuite();
 
@@ -51,7 +52,7 @@
                function setUp()
                {
                        global $DEBUG, $LOCALSERVER, $URI;
-                       $server = split(':', $LOCALSERVER);
+                       $server = explode(':', $LOCALSERVER);
                        if(count($server) > 1)
                        {
                                $this->client=new xmlrpc_client($URI, $server[0], $server[1]);
@@ -1307,7 +1308,7 @@ $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><valu
                        $this->assertEquals(8, $r->faultCode());
 
                        // now test a successful connection
-                       $server = split(':', $LOCALSERVER);
+                       $server = explode(':', $LOCALSERVER);
                        if(count($server) > 1)
                        {
                                $this->client->port = $server[1];
@@ -1409,6 +1410,7 @@ $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><valu
                echo "<h3>Using lib version: $xmlrpcVersion on PHP version: ".phpversion()."</h3>\n";
                echo '<h3>Running '.$suite->testCount().' tests (some of which are multiple) against servers: http://'.htmlspecialchars($LOCALSERVER.$URI).' and https://'.htmlspecialchars($HTTPSSERVER.$HTTPSURI)."\n ...</h3>\n";
                flush();
+           ob_flush();
        }
        else
        {
@@ -1470,4 +1472,4 @@ Proxy Server: <input name="PROXY" size="30" value="<?php echo isset($PROXY) ? ht
 <?php
                echo $result->toHTML()."\n</body>\n</html>\n";
        }
-?>
+?>
\ No newline at end of file