From f498cedcf9d4fe333bebc1192801deccdbc31eb6 Mon Sep 17 00:00:00 2001
From: Robert Munteanu <robert.munteanu@gmail.com>
Date: Wed, 14 Oct 2009 14:58:47 +0300
Subject: [PATCH] Fix #0010982: NuSOAP not playing nice in combination with PHP 5.3.0

The SOAP API does not work under PHP 5.3, since

- mc_api makes use of the deprecated ereg() function
- nusoap uses get_class on arrays
- the soap api uses get_class on arrays

This patch fixes these errors by:

- updating the SOAP API error handler to not report deprecation
  warnings;
- suppresses warnings on the get_class calls in nusoap and the soap API
---
 api/soap/mc_api.php       |    5 +++--
 api/soap/mc_enum_api.php  |    3 ++-
 library/README.libs       |    2 +-
 library/nusoap/nusoap.php |    3 ++-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/api/soap/mc_api.php b/api/soap/mc_api.php
index 707808f..ca34f81 100644
--- a/api/soap/mc_api.php
+++ b/api/soap/mc_api.php
@@ -351,8 +351,9 @@ function mc_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
 	global $l_oServer;
 
 	# check if errors were disabled with @ somewhere in this call chain
-	# also suppress php 5 strict warnings
-	if( 0 == error_reporting() || 2048 == $p_type ) {
+	# also suppress php 5 strict warnings and php 5.3 deprecation
+	# warnings
+	if( 0 == error_reporting() || 2048 == $p_type || 8192 == $p_type) {
 		return;
 	}
 
diff --git a/api/soap/mc_enum_api.php b/api/soap/mc_enum_api.php
index 2922d6c..df06f0d 100644
--- a/api/soap/mc_enum_api.php
+++ b/api/soap/mc_enum_api.php
@@ -166,7 +166,8 @@ function mc_enum_get( $p_username, $p_password, $p_enumeration ) {
  * @return Array  The converted enumeration
  */
 function mci_explode_to_objectref( $p_config_enum_string ) {
-	if( get_class( $p_config_enum_string ) == 'soap_fault' ) {
+	// silence warnings under PHP 5.3 or newer
+	if( @get_class( $p_config_enum_string ) == 'soap_fault' ) {
 		return $p_config_enum_string;
 	}
 	
diff --git a/library/README.libs b/library/README.libs
index 41a025d..5754dcb 100644
--- a/library/README.libs
+++ b/library/README.libs
@@ -7,7 +7,7 @@ directory       | project         | version  | status
 adodb           | adodb           | 5.0.9a   | patched: various, see git
 disposable      | disposable      | 1.1.0    | unpatched
 ezc             | ez Components   | 2009.1.2 | unpatched
-nusoap          | nusoap          | 0.7.3    | unpatched
+nusoap          | nusoap          | 0.7.3    | patched: suppress get_class warnings
 phpmailer       | PHPMailer       | 5.0.2    | unpatched
 projax          | projax          |          | unpatched
 rssbuilder      | RSSBuilder      | 2.2.1    | patched: removed __autoload function
diff --git a/library/nusoap/nusoap.php b/library/nusoap/nusoap.php
index cadf93d..47d13b4 100644
--- a/library/nusoap/nusoap.php
+++ b/library/nusoap/nusoap.php
@@ -4018,7 +4018,8 @@ class nusoap_server extends nusoap_base {
 	function serialize_return() {
 		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
 		// if fault
-		if (isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
+		// get_class errors are suppressed since they trigger warnings on PHP >= 5.3
+		if (isset($this->methodreturn) && ((@get_class($this->methodreturn) == 'soap_fault') || (@get_class($this->methodreturn) == 'nusoap_fault'))) {
 			$this->debug('got a fault object from method');
 			$this->fault = $this->methodreturn;
 			return;
-- 
1.6.4.2

