fixes for php 8
authorgggeek <giunta.gaetano@gmail.com>
Fri, 11 Dec 2020 17:15:45 +0000 (17:15 +0000)
committergggeek <giunta.gaetano@gmail.com>
Fri, 11 Dec 2020 17:15:45 +0000 (17:15 +0000)
NEWS
README.md
debugger/action.php
debugger/common.php
src/PhpXmlRpc.php
src/Server.php
src/Wrapper.php

diff --git a/NEWS b/NEWS
index 56c0938..529a76e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+XML-RPC for PHP version 4.4.3 - unreleased
+
+* fixed: compatibility with PHP 8.0 (fixes to the debugger, to the server's 'system.methodHelp' method and to the
+  PhpXmlRpc\Wrapper class)
+
+* improvements to the test stack: it is now possible to run it via Docker besides Travis; avoid using _any_ external
+  server when running tests
+
+
 XML-RPC for PHP version 4.4.2 - 2020/3/4
 
 * fixed: `client->setCookie()` bug: cookie values that contain spaces are now properly encoded in a way that gets them
index d78a196..63cece5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -11,13 +11,16 @@ Detailed installation instructions are in the [INSTALL.md](INSTALL.md) file, alo
 Documentation
 -------------
 
-*NB: the user manual has not been updated yet with all the changes made in version 4. Please consider it unreliable!*
-
-*You are encouraged to look instead the code examples found in the demo/ directory*
+See the documentation page at [gggeek.github.io/phpxmlrpc](https://gggeek.github.io/phpxmlrpc) for a list of the
+library main features and all project related information.
 
 The user manual can be found in the doc/manual directory, in Asciidoc format: [phpxmlrpc_manual.adoc](doc/manual/phpxmlrpc_manual.adoc)
 
-Release tarballs also contain the HTML and PDF versions, as well as an automatically generated API documentation.
+Release tarballs also contain HTML and PDF versions of the manual, as well as an automatically generated API documentation.
+
+*NB: the user manual has not been updated yet with all the changes made in version 4. Please consider it unreliable!*
+
+*You are encouraged to look instead the code examples found in the demo/ directory*
 
 Upgrading
 ---------
index 0474bfe..076b1c0 100644 (file)
@@ -199,7 +199,7 @@ if ($action) {
         case 'wrap':
             $msg[0] = new $requestClass('system.methodHelp', array(), $id);
             $msg[0]->addparam(new PhpXmlRpc\Value($method));
-            $msg[1] = new $requestClass('system.methodSignature', array(), $id + 1);
+            $msg[1] = new $requestClass('system.methodSignature', array(), (int)$id + 1);
             $msg[1]->addparam(new PhpXmlRpc\Value($method));
             $actionname = 'Description of method "' . $method . '"';
             break;
@@ -475,7 +475,7 @@ if ($action) {
                         $encoder = new PhpXmlRpc\Encoder();
                         $msig = $encoder->decode($r2);
                         $msig = $msig[$methodsig];
-                        $proto = $protocol == 2 ? 'https' : $protocol == 1 ? 'http11' : '';
+                        $proto = $protocol == 2 ? 'https' : ( $protocol == 1 ? 'http11' : '' );
                         if ($proxy == '' && $username == '' && !$requestcompression && !$responsecompression &&
                             $clientcookies == ''
                         ) {
@@ -541,6 +541,7 @@ if ($action) {
 
     <h3>Changelog</h3>
     <ul>
+        <li>2020-12-11: fix problems with running the debugger on php 8</li>
         <li>2015-05-30: fix problems with generating method payloads for NIL and Undefined parameters</li>
         <li>2015-04-19: fix problems with LATIN-1 characters in payload</li>
         <li>2007-02-20: add visual editor for method payload; allow strings, bools as jsonrpc msg id</li>
index 649de51..c3efa33 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 // work around magic quotes
-if (get_magic_quotes_gpc()) {
+if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
     function stripslashes_deep($value)
     {
         $value = is_array($value) ?
index 1e8db7d..d59e147 100644 (file)
@@ -78,7 +78,7 @@ class PhpXmlRpc
     public static $xmlrpc_internalencoding = "UTF-8";
 
     public static $xmlrpcName = "XML-RPC for PHP";
-    public static $xmlrpcVersion = "4.4.2";
+    public static $xmlrpcVersion = "4.4.3-dev";
 
     // let user errors start at 800
     public static $xmlrpcerruser = 800;
index bd21d68..3516f94 100644 (file)
@@ -698,7 +698,6 @@ class Server
                         }
                     }
                     throw $e;
-                    break;
                 case 1:
                     $r = new Response(0, $e->getCode(), $e->getMessage());
                     break;
@@ -914,7 +913,7 @@ class Server
         }
         if (isset($dmap[$methName])) {
             if (isset($dmap[$methName]['docstring'])) {
-                $r = new Response(new Value($dmap[$methName]['docstring']), 'string');
+                $r = new Response(new Value($dmap[$methName]['docstring'], 'string'));
             } else {
                 $r = new Response(new Value('', 'string'));
             }
index cdfb41f..a3572ae 100644 (file)
@@ -678,7 +678,7 @@ class Wrapper
      *                            - bool    debug               set it to 1 or 2 to see debug results of querying server for method synopsis
      *                            - int     simple_client_copy  set it to 1 to have a lightweight copy of the $client object made in the generated code (only used when return_source = true)
      *
-     * @return \closure|array|false false on failure, closure by default and array for return_source = true
+     * @return \closure|string[]|false false on failure, closure by default and array for return_source = true
      */
     public function wrapXmlrpcMethod($client, $methodName, $extraOptions = array())
     {
@@ -885,7 +885,7 @@ class Wrapper
      * @param string $newFuncName
      * @param array $mSig
      * @param string $mDesc
-     * @return array
+     * @return string[] keys: source, docstring
      */
     public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='')
     {
@@ -1106,7 +1106,12 @@ class Wrapper
         // (this provides for future expansion or subclassing of client obj)
         if ($verbatimClientCopy) {
             foreach ($client as $fld => $val) {
-                if ($fld != 'debug' && $fld != 'return_type') {
+                /// @todo in php 8.0, curl handles became objects, but they have no __set_state, thus var_export will
+                ///        fail for xmlrpc_curl_handle. So we disabled copying it.
+                ///        We should examine in depth if this change can have side effects - at first sight if the
+                ///        client's curl handle is not set, all curl options are (re)set on each http call, so there
+                ///        should be no loss of state...
+                if ($fld != 'debug' && $fld != 'return_type' && $fld != 'xmlrpc_curl_handle') {
                     $val = var_export($val, true);
                     $code .= "\$client->$fld = $val;\n";
                 }