WIP fix bugs after introduction of namespaces, found trying to run the testsuite
authorgggeek <giunta.gaetano@gmail.com>
Sun, 14 Dec 2014 23:23:23 +0000 (23:23 +0000)
committergggeek <giunta.gaetano@gmail.com>
Sun, 14 Dec 2014 23:23:23 +0000 (23:23 +0000)
debugger/action.php
demo/client/wrap.php
demo/server/server.php
lib/xmlrpc.inc
src/Encoder.php
src/PhpXmlRpc.php
src/Response.php
src/Server.php
src/Value.php

index f56946c..fae2065 100644 (file)
@@ -149,10 +149,10 @@ td form {margin: 0;}
     switch ($action) {
 
       case 'wrap':
-        @include('xmlrpc_wrappers.php');
+        @include('xmlrpc_wrappers.inc');
         if (!function_exists('build_remote_method_wrapper_code'))
         {
-          die('Error: to enable creation of method stubs the xmlrpc_wrappers.php file is needed');
+          die('Error: to enable creation of method stubs the xmlrpc_wrappers.inc file is needed');
         }
         // fall thru intentionally
       case 'describe':
index faae4bf..8ec452c 100644 (file)
@@ -9,7 +9,7 @@
 </h3>
 <?php
     include("xmlrpc.inc");
-    include("xmlrpc_wrappers.php");
+    include("xmlrpc_wrappers.inc");
 
     $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
     $c->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals
index d17f73c..853dc4b 100644 (file)
@@ -19,7 +19,7 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource']))
 
     include("xmlrpc.inc");
     include("xmlrpcs.inc");
-    include("xmlrpc_wrappers.php");
+    include("xmlrpc_wrappers.inc");
 
     /**
     * Used to test usage of object methods in dispatch maps and in wrapper code
index c706758..57a0adc 100644 (file)
@@ -49,6 +49,10 @@ include_once(__DIR__.'/../src/Response.php');
 include_once(__DIR__.'/../src/Client.php');
 include_once(__DIR__.'/../src/Encoder.php');
 
+
+/* Expose the global variables which used to be defined */
+PhpXmlRpc\PhpXmlRpc::exportGlobals();
+
 /* Expose with the old names the classes which have been namespaced */
 
 class xmlrpcval extends PhpXmlRpc\Value
index f464f82..d687467 100644 (file)
@@ -185,7 +185,7 @@ class Encoder
                 }
                 break;
             case 'object':
-                if(is_a($php_val, 'xmlrpcval'))
+                if(is_a($php_val, 'PhpXmlRpc\Value'))
                 {
                     $xmlrpc_val = $php_val;
                 }
index 201ba63..dc0c4ab 100644 (file)
@@ -83,4 +83,39 @@ class PhpXmlRpc
     public static $xmlrpc_null_apache_encoding = false;
 
     public static $xmlrpc_null_apache_encoding_ns = "http://ws.apache.org/xmlrpc/namespaces/extensions";
+
+    /**
+     * A function to be used for compatibility with legacy code: it creates all global variables which used to be declared,
+     * such as library version etc...
+     */
+    public static function exportGlobals()
+    {
+        $reflection = new \ReflectionClass('PhpXmlRpc\PhpXmlRpc');
+        $staticProperties = $reflection->getStaticProperties();
+        foreach ($staticProperties as $name => $value)
+        {
+            $GLOBALS[$name] = $value;
+        }
+    }
+
+    /**
+     * A function to be used for compatibility with legacy code: it gets the values of all global variables which used
+     * to be declared, such as library version etc... and sets them to php classes.
+     * It should be used by code which changed the values of those global variables to alter the working of the library.
+     * Example code:
+     * 1. include xmlrpc.inc
+     * 2. set the values, e.g. $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
+     * 3. import them: PhpXmlRpc\PhpXmlRpc::importGlobals();
+     * 4. run your own code
+     */
+    public static function importGlobals()
+    {
+        $reflection = new \ReflectionClass('PhpXmlRpc\PhpXmlRpc');
+        $staticProperties = $reflection->getStaticProperties();
+        foreach ($staticProperties as $name => $value)
+        {
+            if(isset($GLOBALS[$name]))
+                self::$$name = $GLOBALS[$name];
+        }
+    }
 }
index 5f0f6ec..bd205a8 100644 (file)
@@ -139,7 +139,7 @@ Charset::instance()->encode_entitites($this->errstr, PhpXmlRpc::$xmlrpc_internal
         }
         else
         {
-            if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval'))
+            if(!is_object($this->val) || !is_a($this->val, 'PhpXmlRpc\Value'))
             {
                 if (is_string($this->val) && $this->valtyp == 'xml')
                 {
index a3cde97..74acb06 100644 (file)
@@ -740,7 +740,7 @@ class Server
                 if (!is_a($r, 'xmlrpcresp'))
                 {
                     error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler does not return an xmlrpcresp object");
-                    if (is_a($r, 'xmlrpcval'))
+                    if (is_a($r, 'PhpXmlRpc\Value'))
                     {
                         $r = new Response($r);
                     }
index fd4a840..04df2eb 100644 (file)
@@ -130,10 +130,10 @@ class Value
         switch($this->mytype)
         {
             case 1:
-                error_log('XML-RPC: '.__METHOD__.': scalar xmlrpcval can have only one value');
+                error_log('XML-RPC: '.__METHOD__.': scalar xmlrpc value can have only one value');
                 return 0;
             case 3:
-                error_log('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpcval');
+                error_log('XML-RPC: '.__METHOD__.': cannot add anonymous scalar to struct xmlrpc value');
                 return 0;
             case 2:
                 // we're adding a scalar value to an array here
@@ -464,9 +464,9 @@ class Value
     {
         reset($this->me);
         list($a,)=each($this->me);
-        if($a==static::xmlrpcI4)
+        if($a==static::$xmlrpcI4)
         {
-            $a=static::xmlrpcInt;
+            $a=static::$xmlrpcInt;
         }
         return $a;
     }