Skip to content

Commit

Permalink
WIP fix bugs after introduction of namespaces, found trying to run th…
Browse files Browse the repository at this point in the history
…e testsuite
  • Loading branch information
gggeek committed Dec 14, 2014
1 parent 64b37df commit e2ef082
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 11 deletions.
4 changes: 2 additions & 2 deletions debugger/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@
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':
Expand Down
2 changes: 1 addition & 1 deletion demo/client/wrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion demo/server/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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
Expand Down
4 changes: 4 additions & 0 deletions lib/xmlrpc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function encode($php_val, $options=array())
}
break;
case 'object':
if(is_a($php_val, 'xmlrpcval'))
if(is_a($php_val, 'PhpXmlRpc\Value'))
{
$xmlrpc_val = $php_val;
}
Expand Down
35 changes: 35 additions & 0 deletions src/PhpXmlRpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
}
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function serialize($charset_encoding='')
}
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')
{
Expand Down
2 changes: 1 addition & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ protected function execute($m, $params=null, $paramtypes=null)
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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ function addScalar($val, $type='string')
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
Expand Down Expand Up @@ -464,9 +464,9 @@ public function scalartyp()
{
reset($this->me);
list($a,)=each($this->me);
if($a==static::xmlrpcI4)
if($a==static::$xmlrpcI4)
{
$a=static::xmlrpcInt;
$a=static::$xmlrpcInt;
}
return $a;
}
Expand Down

0 comments on commit e2ef082

Please sign in to comment.