View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0010982 | mantisbt | api soap | public | 2009-09-24 05:57 | 2010-02-22 14:34 |
Reporter | thijsputman | Assigned To | rombert | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.1.6 | ||||
Target Version | 1.2.0 | Fixed in Version | 1.2.0 | ||
Summary | 0010982: NuSOAP not playing nice in combination with PHP 5.3.0 | ||||
Description | After upgrading my PHP installation to 5.3.0, the SOAP API started generating a stream of E_DEPRECATED errors. After some tinkering, I managed to get Mantis to ignore these errors. But, there was still an error preventing the API from functioning properly: NuSOAP calls get_class() on an array which, since PHP 5.3.0, generates an E_WARNING. Adding error suppression to the two calls to get_class() at the start of serialize_return() in "api/soap/nusoap/nusoap.php" solves this problem. I am although not intimately familiar with NuSOAP, so this might not be the best long-term solution, nor take care of all potential issues. I haven't checked out any more recent versions of NuSOAP, but since the last release was at the end of 2007 I don't really expect this problem to be resolved there... | ||||
Tags | patch | ||||
Attached Files | 0001-Fix-0010982-NuSOAP-not-playing-nice-in-combination-w.patch (3,579 bytes)
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 0001-php-5.3-support-for-the-soap-interface.patch (28,861 bytes)
From a3f8357f64c8482b71defe235b2d38e57f38ffeb Mon Sep 17 00:00:00 2001 From: Pier-Luc Duchaine <pierduch@gmail.com> Date: Wed, 21 Oct 2009 08:09:10 -0400 Subject: [PATCH] php 5.3 support for the soap interface --- api/soap/mantisconnect.php | 2 +- library/nusoap/class.nusoap_base.php | 20 ++++--- library/nusoap/class.soap_parser.php | 6 +- library/nusoap/class.soap_server.php | 12 ++-- library/nusoap/class.soap_transport_http.php | 6 +- library/nusoap/class.soapclient.php | 8 ++-- library/nusoap/class.wsdl.php | 8 ++-- library/nusoap/class.xmlschema.php | 8 ++-- library/nusoap/nusoap.php | 73 +++++++++++++------------ 9 files changed, 74 insertions(+), 69 deletions(-) diff --git a/api/soap/mantisconnect.php b/api/soap/mantisconnect.php index 938e318..ca0f4cc 100644 --- a/api/soap/mantisconnect.php +++ b/api/soap/mantisconnect.php @@ -1356,7 +1356,7 @@ function mci_is_webservice_call( $p_service, $p_data ) $t_qs = $QUERY_STRING; } - if ( isset( $t_qs ) && ereg( 'wsdl', $t_qs ) ){ + if ( isset( $t_qs ) && preg_match( '/wsdl/', $t_qs ) ){ return false; } else if ( $p_data == '' && $p_service->wsdl ) { return false; diff --git a/library/nusoap/class.nusoap_base.php b/library/nusoap/class.nusoap_base.php index 8486b82..edcaf63 100644 --- a/library/nusoap/class.nusoap_base.php +++ b/library/nusoap/class.nusoap_base.php @@ -104,7 +104,7 @@ class nusoap_base { * @var string * @access private */ - var $revision = '$Revision$'; + var $revision = '$Revision: X.XX $'; /** * Current error string (manipulated by getError/setError) * @@ -562,7 +562,7 @@ class nusoap_base { case (is_array($val) || $type): // detect if struct or array $valueType = $this->isArraySimpleOrStruct($val); - if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){ + if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ $this->debug("serialize_val: serialize array"); $i = 0; if(is_array($val) && count($val)> 0){ @@ -765,7 +765,7 @@ class nusoap_base { */ function expandQname($qname){ // get element prefix - if(strpos($qname,':') && !ereg('^http://',$qname)){ + if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ // get unqualified name $name = substr(strstr($qname,':'),1); // get ns prefix @@ -904,7 +904,7 @@ class nusoap_base { function timestamp_to_iso8601($timestamp,$utc=true){ $datestr = date('Y-m-d\TH:i:sO',$timestamp); if($utc){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -912,9 +912,10 @@ function timestamp_to_iso8601($timestamp,$utc=true){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; - if(ereg($eregStr,$datestr,$regs)){ + if(preg_match($pattern,$datestr,$regs)){ return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); } return false; @@ -930,7 +931,7 @@ function timestamp_to_iso8601($timestamp,$utc=true){ * @access public */ function iso8601_to_timestamp($datestr){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -938,8 +939,9 @@ function iso8601_to_timestamp($datestr){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - if(ereg($eregStr,$datestr,$regs)){ + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + if(preg_match($pattern,$datestr,$regs)){ // not utc if($regs[8] != 'Z'){ $op = substr($regs[8],0,1); diff --git a/library/nusoap/class.soap_parser.php b/library/nusoap/class.soap_parser.php index b728c1a..32f7a7f 100644 --- a/library/nusoap/class.soap_parser.php +++ b/library/nusoap/class.soap_parser.php @@ -207,7 +207,7 @@ class nusoap_parser extends nusoap_base { $key_localpart = $this->getLocalPart($key); // if ns declarations, add to class level array of valid namespaces if($key_prefix == 'xmlns'){ - if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){ + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ $this->XMLSchemaVersion = $value; $this->namespaces['xsd'] = $this->XMLSchemaVersion; $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; @@ -243,8 +243,8 @@ class nusoap_parser extends nusoap_base { [5] length ::= nextDimension* Digit+ [6] nextDimension ::= Digit+ ',' */ - $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; - if(ereg($expr,$value,$regs)){ + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; + if(preg_match($expr,$value,$regs)){ $this->message[$pos]['typePrefix'] = $regs[1]; $this->message[$pos]['arrayTypePrefix'] = $regs[1]; if (isset($this->namespaces[$regs[1]])) { diff --git a/library/nusoap/class.soap_server.php b/library/nusoap/class.soap_server.php index fb6f075..d187908 100644 --- a/library/nusoap/class.soap_server.php +++ b/library/nusoap/class.soap_server.php @@ -245,7 +245,7 @@ class nusoap_server extends nusoap_base { } $this->debug("In service, query string=$qs"); - if (ereg('wsdl', $qs) ){ + if (preg_match('/wsdl/', $qs) ){ $this->debug("In service, this is a request for WSDL"); if($this->externalWSDLURL){ if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL @@ -316,7 +316,7 @@ class nusoap_server extends nusoap_base { // get the character encoding of the incoming request if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){ $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1)); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -345,7 +345,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -379,7 +379,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -717,7 +717,7 @@ class nusoap_server extends nusoap_base { $payload .= $this->getDebugAsXMLComment(); } $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")"; // Let the Web server decide about this //$this->outgoing_headers[] = "Connection: Close\r\n"; @@ -805,7 +805,7 @@ class nusoap_server extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; diff --git a/library/nusoap/class.soap_transport_http.php b/library/nusoap/class.soap_transport_http.php index 34ce5f3..02da100 100644 --- a/library/nusoap/class.soap_transport_http.php +++ b/library/nusoap/class.soap_transport_http.php @@ -66,7 +66,7 @@ class soap_transport_http extends nusoap_base { $this->ch_options = $curl_options; } $this->use_curl = $use_curl; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); } @@ -829,7 +829,7 @@ class soap_transport_http extends nusoap_base { } } // remove 100 headers - if (isset($lb) && ereg('^HTTP/1.1 100',$data)) { + if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) { unset($lb); $data = ''; }// @@ -995,7 +995,7 @@ class soap_transport_http extends nusoap_base { if ($data == '') { // have nothing left; just remove 100 header(s) $data = $savedata; - while (ereg('^HTTP/1.1 100',$data)) { + while (preg_match('/^HTTP\/1.1 100/',$data)) { if ($pos = strpos($data,"\r\n\r\n")) { $data = ltrim(substr($data,$pos)); } elseif($pos = strpos($data,"\n\n") ) { diff --git a/library/nusoap/class.soapclient.php b/library/nusoap/class.soapclient.php index 3735099..96a0171 100644 --- a/library/nusoap/class.soapclient.php +++ b/library/nusoap/class.soapclient.php @@ -406,7 +406,7 @@ class nusoap_client extends nusoap_base { // detect transport switch(true){ // http(s) - case ereg('^http',$this->endpoint): + case preg_match('/^http/',$this->endpoint): $this->debug('transporting via HTTP'); if($this->persistentConnection == true && is_object($this->persistentConnection)){ $http =& $this->persistentConnection; @@ -428,10 +428,10 @@ class nusoap_client extends nusoap_base { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length='.strlen($msg)); - if(ereg('^http:',$this->endpoint)){ + if(preg_match('/^http:/',$this->endpoint)){ //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); - } elseif(ereg('^https',$this->endpoint)){ + } elseif(preg_match('/^https/',$this->endpoint)){ //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout,$response_timeout); @@ -490,7 +490,7 @@ class nusoap_client extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; diff --git a/library/nusoap/class.wsdl.php b/library/nusoap/class.wsdl.php index 73094ab..93b1a40 100644 --- a/library/nusoap/class.wsdl.php +++ b/library/nusoap/class.wsdl.php @@ -302,7 +302,7 @@ class wsdl extends nusoap_base { $this->currentSchema->schemaStartElement($parser, $name, $attrs); $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); - } elseif (ereg('schema$', $name)) { + } elseif (preg_match('/schema$/', $name)) { $this->debug('Parsing WSDL schema'); // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); $this->status = 'schema'; @@ -321,7 +321,7 @@ class wsdl extends nusoap_base { if (count($attrs) > 0) { // register namespace declarations foreach($attrs as $k => $v) { - if (ereg("^xmlns", $k)) { + if (preg_match('/^xmlns/',$k)) { if ($ns_prefix = substr(strrchr($k, ':'), 1)) { $this->namespaces[$ns_prefix] = $v; } else { @@ -346,7 +346,7 @@ class wsdl extends nusoap_base { $attrs = array(); } // get element prefix, namespace and name - if (ereg(':', $name)) { + if (preg_match('/:/', $name)) { // get ns prefix $prefix = substr($name, 0, strpos($name, ':')); // get ns @@ -511,7 +511,7 @@ class wsdl extends nusoap_base { */ function end_element($parser, $name){ // unset schema status - if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) { + if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { $this->status = ""; $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); diff --git a/library/nusoap/class.xmlschema.php b/library/nusoap/class.xmlschema.php index 2bfd97b..b0ace48 100644 --- a/library/nusoap/class.xmlschema.php +++ b/library/nusoap/class.xmlschema.php @@ -199,7 +199,7 @@ class nusoap_xmlschema extends nusoap_base { if(count($attrs) > 0){ foreach($attrs as $k => $v){ // if ns declarations, add to class level array of valid namespaces - if(ereg("^xmlns",$k)){ + if(preg_match('/^xmlns/',$k)){ //$this->xdebug("$k: $v"); //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); if($ns_prefix = substr(strrchr($k,':'),1)){ @@ -311,7 +311,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -331,7 +331,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -741,7 +741,7 @@ class nusoap_xmlschema extends nusoap_base { } elseif(isset($this->attributes[$type])){ $this->xdebug("in getTypeDef, found attribute $type"); return $this->attributes[$type]; - } elseif (ereg('_ContainedType$', $type)) { + } elseif (preg_match('/_ContainedType$/', $type)) { $this->xdebug("in getTypeDef, have an untyped element $type"); $typeDef['typeClass'] = 'simpleType'; $typeDef['phpType'] = 'scalar'; diff --git a/library/nusoap/nusoap.php b/library/nusoap/nusoap.php index cadf93d..c030999 100644 --- a/library/nusoap/nusoap.php +++ b/library/nusoap/nusoap.php @@ -104,7 +104,7 @@ class nusoap_base { * @var string * @access private */ - var $revision = '$Revision$'; + var $revision = '$Revision: 1.62 $'; /** * Current error string (manipulated by getError/setError) * @@ -562,7 +562,7 @@ class nusoap_base { case (is_array($val) || $type): // detect if struct or array $valueType = $this->isArraySimpleOrStruct($val); - if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){ + if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ $this->debug("serialize_val: serialize array"); $i = 0; if(is_array($val) && count($val)> 0){ @@ -765,7 +765,7 @@ class nusoap_base { */ function expandQname($qname){ // get element prefix - if(strpos($qname,':') && !ereg('^http://',$qname)){ + if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ // get unqualified name $name = substr(strstr($qname,':'),1); // get ns prefix @@ -904,7 +904,7 @@ class nusoap_base { function timestamp_to_iso8601($timestamp,$utc=true){ $datestr = date('Y-m-d\TH:i:sO',$timestamp); if($utc){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -912,9 +912,10 @@ function timestamp_to_iso8601($timestamp,$utc=true){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - - if(ereg($eregStr,$datestr,$regs)){ + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + + if(preg_match($pattern,$datestr,$regs)){ return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); } return false; @@ -930,7 +931,7 @@ function timestamp_to_iso8601($timestamp,$utc=true){ * @access public */ function iso8601_to_timestamp($datestr){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -938,8 +939,10 @@ function iso8601_to_timestamp($datestr){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - if(ereg($eregStr,$datestr,$regs)){ + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + + if(preg_match($pattern,$datestr,$regs)){ // not utc if($regs[8] != 'Z'){ $op = substr($regs[8],0,1); @@ -1267,7 +1270,7 @@ class nusoap_xmlschema extends nusoap_base { if(count($attrs) > 0){ foreach($attrs as $k => $v){ // if ns declarations, add to class level array of valid namespaces - if(ereg("^xmlns",$k)){ + if(preg_match('/^xmlns/',$k)){ //$this->xdebug("$k: $v"); //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); if($ns_prefix = substr(strrchr($k,':'),1)){ @@ -1379,7 +1382,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -1399,7 +1402,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -1809,7 +1812,7 @@ class nusoap_xmlschema extends nusoap_base { } elseif(isset($this->attributes[$type])){ $this->xdebug("in getTypeDef, found attribute $type"); return $this->attributes[$type]; - } elseif (ereg('_ContainedType$', $type)) { + } elseif (preg_match('/_ContainedType$/', $type)) { $this->xdebug("in getTypeDef, have an untyped element $type"); $typeDef['typeClass'] = 'simpleType'; $typeDef['phpType'] = 'scalar'; @@ -2173,7 +2176,7 @@ class soap_transport_http extends nusoap_base { $this->ch_options = $curl_options; } $this->use_curl = $use_curl; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); } @@ -2936,7 +2939,7 @@ class soap_transport_http extends nusoap_base { } } // remove 100 headers - if (isset($lb) && ereg('^HTTP/1.1 100',$data)) { + if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) { unset($lb); $data = ''; }// @@ -3102,7 +3105,7 @@ class soap_transport_http extends nusoap_base { if ($data == '') { // have nothing left; just remove 100 header(s) $data = $savedata; - while (ereg('^HTTP/1.1 100',$data)) { + while (preg_match('/^HTTP\/1.1 100/',$data)) { if ($pos = strpos($data,"\r\n\r\n")) { $data = ltrim(substr($data,$pos)); } elseif($pos = strpos($data,"\n\n") ) { @@ -3654,7 +3657,7 @@ class nusoap_server extends nusoap_base { } $this->debug("In service, query string=$qs"); - if (ereg('wsdl', $qs) ){ + if (preg_match('/wsdl/', $qs) ){ $this->debug("In service, this is a request for WSDL"); if($this->externalWSDLURL){ if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL @@ -3725,7 +3728,7 @@ class nusoap_server extends nusoap_base { // get the character encoding of the incoming request if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){ $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1)); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -3754,7 +3757,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -3788,7 +3791,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -4018,7 +4021,7 @@ 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'))) { + if (isset($this->methodreturn) && ((get_class((object)$this->methodreturn) == 'soap_fault') || (get_class((object)$this->methodreturn) == 'nusoap_fault'))) { $this->debug('got a fault object from method'); $this->fault = $this->methodreturn; return; @@ -4126,7 +4129,7 @@ class nusoap_server extends nusoap_base { $payload .= $this->getDebugAsXMLComment(); } $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")"; // Let the Web server decide about this //$this->outgoing_headers[] = "Connection: Close\r\n"; @@ -4214,7 +4217,7 @@ class nusoap_server extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -4781,7 +4784,7 @@ class wsdl extends nusoap_base { $this->currentSchema->schemaStartElement($parser, $name, $attrs); $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); - } elseif (ereg('schema$', $name)) { + } elseif (preg_match('/schema$/', $name)) { $this->debug('Parsing WSDL schema'); // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); $this->status = 'schema'; @@ -4800,7 +4803,7 @@ class wsdl extends nusoap_base { if (count($attrs) > 0) { // register namespace declarations foreach($attrs as $k => $v) { - if (ereg("^xmlns", $k)) { + if (preg_match('/^xmlns/',$k)) { if ($ns_prefix = substr(strrchr($k, ':'), 1)) { $this->namespaces[$ns_prefix] = $v; } else { @@ -4825,7 +4828,7 @@ class wsdl extends nusoap_base { $attrs = array(); } // get element prefix, namespace and name - if (ereg(':', $name)) { + if (preg_match('/:/', $name)) { // get ns prefix $prefix = substr($name, 0, strpos($name, ':')); // get ns @@ -4990,7 +4993,7 @@ class wsdl extends nusoap_base { */ function end_element($parser, $name){ // unset schema status - if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) { + if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { $this->status = ""; $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); @@ -6587,7 +6590,7 @@ class nusoap_parser extends nusoap_base { $key_localpart = $this->getLocalPart($key); // if ns declarations, add to class level array of valid namespaces if($key_prefix == 'xmlns'){ - if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){ + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ $this->XMLSchemaVersion = $value; $this->namespaces['xsd'] = $this->XMLSchemaVersion; $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; @@ -6623,8 +6626,8 @@ class nusoap_parser extends nusoap_base { [5] length ::= nextDimension* Digit+ [6] nextDimension ::= Digit+ ',' */ - $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; - if(ereg($expr,$value,$regs)){ + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; + if(preg_match($expr,$value,$regs)){ $this->message[$pos]['typePrefix'] = $regs[1]; $this->message[$pos]['arrayTypePrefix'] = $regs[1]; if (isset($this->namespaces[$regs[1]])) { @@ -7422,7 +7425,7 @@ class nusoap_client extends nusoap_base { // detect transport switch(true){ // http(s) - case ereg('^http',$this->endpoint): + case preg_match('/^http/',$this->endpoint): $this->debug('transporting via HTTP'); if($this->persistentConnection == true && is_object($this->persistentConnection)){ $http =& $this->persistentConnection; @@ -7444,10 +7447,10 @@ class nusoap_client extends nusoap_base { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length='.strlen($msg)); - if(ereg('^http:',$this->endpoint)){ + if(preg_match('/^http:/',$this->endpoint)){ //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); - } elseif(ereg('^https',$this->endpoint)){ + } elseif(preg_match('/^https/',$this->endpoint)){ //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout,$response_timeout); @@ -7506,7 +7509,7 @@ class nusoap_client extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; -- 1.6.4.msysgit.0 0002-php-5.3-support-for-the-soap-interface.patch (28,319 bytes)
From 2c518c24c573be7cec85c56b5f6850f5618dd84a Mon Sep 17 00:00:00 2001 From: Pier-Luc Duchaine <pierduch@gmail.com> Date: Sun, 25 Oct 2009 12:39:40 -0400 Subject: [PATCH] convert ereg to preg --- library/nusoap/class.nusoap_base.php | 20 ++++--- library/nusoap/class.soap_parser.php | 6 +- library/nusoap/class.soap_server.php | 12 ++-- library/nusoap/class.soap_transport_http.php | 6 +- library/nusoap/class.soapclient.php | 8 ++-- library/nusoap/class.wsdl.php | 8 ++-- library/nusoap/class.xmlschema.php | 8 ++-- library/nusoap/nusoap.php | 73 +++++++++++++------------ 8 files changed, 73 insertions(+), 68 deletions(-) diff --git a/library/nusoap/class.nusoap_base.php b/library/nusoap/class.nusoap_base.php index 8486b82..535532f 100644 --- a/library/nusoap/class.nusoap_base.php +++ b/library/nusoap/class.nusoap_base.php @@ -104,7 +104,7 @@ class nusoap_base { * @var string * @access private */ - var $revision = '$Revision$'; + var $revision = '$Revision: X.XX $'; /** * Current error string (manipulated by getError/setError) * @@ -562,7 +562,7 @@ class nusoap_base { case (is_array($val) || $type): // detect if struct or array $valueType = $this->isArraySimpleOrStruct($val); - if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){ + if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ $this->debug("serialize_val: serialize array"); $i = 0; if(is_array($val) && count($val)> 0){ @@ -765,7 +765,7 @@ class nusoap_base { */ function expandQname($qname){ // get element prefix - if(strpos($qname,':') && !ereg('^http://',$qname)){ + if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ // get unqualified name $name = substr(strstr($qname,':'),1); // get ns prefix @@ -904,7 +904,7 @@ class nusoap_base { function timestamp_to_iso8601($timestamp,$utc=true){ $datestr = date('Y-m-d\TH:i:sO',$timestamp); if($utc){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -912,9 +912,10 @@ function timestamp_to_iso8601($timestamp,$utc=true){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; - if(ereg($eregStr,$datestr,$regs)){ + if(preg_match($pattern,$datestr,$regs)){ return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); } return false; @@ -930,7 +931,7 @@ function timestamp_to_iso8601($timestamp,$utc=true){ * @access public */ function iso8601_to_timestamp($datestr){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -938,8 +939,9 @@ function iso8601_to_timestamp($datestr){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - if(ereg($eregStr,$datestr,$regs)){ + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + if(preg_match($pattern,$datestr,$regs)){ // not utc if($regs[8] != 'Z'){ $op = substr($regs[8],0,1); diff --git a/library/nusoap/class.soap_parser.php b/library/nusoap/class.soap_parser.php index b728c1a..32f7a7f 100644 --- a/library/nusoap/class.soap_parser.php +++ b/library/nusoap/class.soap_parser.php @@ -207,7 +207,7 @@ class nusoap_parser extends nusoap_base { $key_localpart = $this->getLocalPart($key); // if ns declarations, add to class level array of valid namespaces if($key_prefix == 'xmlns'){ - if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){ + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ $this->XMLSchemaVersion = $value; $this->namespaces['xsd'] = $this->XMLSchemaVersion; $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; @@ -243,8 +243,8 @@ class nusoap_parser extends nusoap_base { [5] length ::= nextDimension* Digit+ [6] nextDimension ::= Digit+ ',' */ - $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; - if(ereg($expr,$value,$regs)){ + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; + if(preg_match($expr,$value,$regs)){ $this->message[$pos]['typePrefix'] = $regs[1]; $this->message[$pos]['arrayTypePrefix'] = $regs[1]; if (isset($this->namespaces[$regs[1]])) { diff --git a/library/nusoap/class.soap_server.php b/library/nusoap/class.soap_server.php index fb6f075..d187908 100644 --- a/library/nusoap/class.soap_server.php +++ b/library/nusoap/class.soap_server.php @@ -245,7 +245,7 @@ class nusoap_server extends nusoap_base { } $this->debug("In service, query string=$qs"); - if (ereg('wsdl', $qs) ){ + if (preg_match('/wsdl/', $qs) ){ $this->debug("In service, this is a request for WSDL"); if($this->externalWSDLURL){ if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL @@ -316,7 +316,7 @@ class nusoap_server extends nusoap_base { // get the character encoding of the incoming request if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){ $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1)); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -345,7 +345,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -379,7 +379,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -717,7 +717,7 @@ class nusoap_server extends nusoap_base { $payload .= $this->getDebugAsXMLComment(); } $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")"; // Let the Web server decide about this //$this->outgoing_headers[] = "Connection: Close\r\n"; @@ -805,7 +805,7 @@ class nusoap_server extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; diff --git a/library/nusoap/class.soap_transport_http.php b/library/nusoap/class.soap_transport_http.php index 34ce5f3..02da100 100644 --- a/library/nusoap/class.soap_transport_http.php +++ b/library/nusoap/class.soap_transport_http.php @@ -66,7 +66,7 @@ class soap_transport_http extends nusoap_base { $this->ch_options = $curl_options; } $this->use_curl = $use_curl; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); } @@ -829,7 +829,7 @@ class soap_transport_http extends nusoap_base { } } // remove 100 headers - if (isset($lb) && ereg('^HTTP/1.1 100',$data)) { + if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) { unset($lb); $data = ''; }// @@ -995,7 +995,7 @@ class soap_transport_http extends nusoap_base { if ($data == '') { // have nothing left; just remove 100 header(s) $data = $savedata; - while (ereg('^HTTP/1.1 100',$data)) { + while (preg_match('/^HTTP\/1.1 100/',$data)) { if ($pos = strpos($data,"\r\n\r\n")) { $data = ltrim(substr($data,$pos)); } elseif($pos = strpos($data,"\n\n") ) { diff --git a/library/nusoap/class.soapclient.php b/library/nusoap/class.soapclient.php index 3735099..96a0171 100644 --- a/library/nusoap/class.soapclient.php +++ b/library/nusoap/class.soapclient.php @@ -406,7 +406,7 @@ class nusoap_client extends nusoap_base { // detect transport switch(true){ // http(s) - case ereg('^http',$this->endpoint): + case preg_match('/^http/',$this->endpoint): $this->debug('transporting via HTTP'); if($this->persistentConnection == true && is_object($this->persistentConnection)){ $http =& $this->persistentConnection; @@ -428,10 +428,10 @@ class nusoap_client extends nusoap_base { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length='.strlen($msg)); - if(ereg('^http:',$this->endpoint)){ + if(preg_match('/^http:/',$this->endpoint)){ //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); - } elseif(ereg('^https',$this->endpoint)){ + } elseif(preg_match('/^https/',$this->endpoint)){ //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout,$response_timeout); @@ -490,7 +490,7 @@ class nusoap_client extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; diff --git a/library/nusoap/class.wsdl.php b/library/nusoap/class.wsdl.php index 73094ab..93b1a40 100644 --- a/library/nusoap/class.wsdl.php +++ b/library/nusoap/class.wsdl.php @@ -302,7 +302,7 @@ class wsdl extends nusoap_base { $this->currentSchema->schemaStartElement($parser, $name, $attrs); $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); - } elseif (ereg('schema$', $name)) { + } elseif (preg_match('/schema$/', $name)) { $this->debug('Parsing WSDL schema'); // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); $this->status = 'schema'; @@ -321,7 +321,7 @@ class wsdl extends nusoap_base { if (count($attrs) > 0) { // register namespace declarations foreach($attrs as $k => $v) { - if (ereg("^xmlns", $k)) { + if (preg_match('/^xmlns/',$k)) { if ($ns_prefix = substr(strrchr($k, ':'), 1)) { $this->namespaces[$ns_prefix] = $v; } else { @@ -346,7 +346,7 @@ class wsdl extends nusoap_base { $attrs = array(); } // get element prefix, namespace and name - if (ereg(':', $name)) { + if (preg_match('/:/', $name)) { // get ns prefix $prefix = substr($name, 0, strpos($name, ':')); // get ns @@ -511,7 +511,7 @@ class wsdl extends nusoap_base { */ function end_element($parser, $name){ // unset schema status - if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) { + if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { $this->status = ""; $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); diff --git a/library/nusoap/class.xmlschema.php b/library/nusoap/class.xmlschema.php index 2bfd97b..b0ace48 100644 --- a/library/nusoap/class.xmlschema.php +++ b/library/nusoap/class.xmlschema.php @@ -199,7 +199,7 @@ class nusoap_xmlschema extends nusoap_base { if(count($attrs) > 0){ foreach($attrs as $k => $v){ // if ns declarations, add to class level array of valid namespaces - if(ereg("^xmlns",$k)){ + if(preg_match('/^xmlns/',$k)){ //$this->xdebug("$k: $v"); //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); if($ns_prefix = substr(strrchr($k,':'),1)){ @@ -311,7 +311,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -331,7 +331,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -741,7 +741,7 @@ class nusoap_xmlschema extends nusoap_base { } elseif(isset($this->attributes[$type])){ $this->xdebug("in getTypeDef, found attribute $type"); return $this->attributes[$type]; - } elseif (ereg('_ContainedType$', $type)) { + } elseif (preg_match('/_ContainedType$/', $type)) { $this->xdebug("in getTypeDef, have an untyped element $type"); $typeDef['typeClass'] = 'simpleType'; $typeDef['phpType'] = 'scalar'; diff --git a/library/nusoap/nusoap.php b/library/nusoap/nusoap.php index cadf93d..54da24f 100644 --- a/library/nusoap/nusoap.php +++ b/library/nusoap/nusoap.php @@ -104,7 +104,7 @@ class nusoap_base { * @var string * @access private */ - var $revision = '$Revision$'; + var $revision = '$Revision: X.XX $'; /** * Current error string (manipulated by getError/setError) * @@ -562,7 +562,7 @@ class nusoap_base { case (is_array($val) || $type): // detect if struct or array $valueType = $this->isArraySimpleOrStruct($val); - if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){ + if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ $this->debug("serialize_val: serialize array"); $i = 0; if(is_array($val) && count($val)> 0){ @@ -765,7 +765,7 @@ class nusoap_base { */ function expandQname($qname){ // get element prefix - if(strpos($qname,':') && !ereg('^http://',$qname)){ + if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ // get unqualified name $name = substr(strstr($qname,':'),1); // get ns prefix @@ -904,7 +904,7 @@ class nusoap_base { function timestamp_to_iso8601($timestamp,$utc=true){ $datestr = date('Y-m-d\TH:i:sO',$timestamp); if($utc){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -912,9 +912,10 @@ function timestamp_to_iso8601($timestamp,$utc=true){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - - if(ereg($eregStr,$datestr,$regs)){ + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + + if(preg_match($pattern,$datestr,$regs)){ return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); } return false; @@ -930,7 +931,7 @@ function timestamp_to_iso8601($timestamp,$utc=true){ * @access public */ function iso8601_to_timestamp($datestr){ - $eregStr = + $pattern = '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -938,8 +939,10 @@ function iso8601_to_timestamp($datestr){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - if(ereg($eregStr,$datestr,$regs)){ + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + + if(preg_match($pattern,$datestr,$regs)){ // not utc if($regs[8] != 'Z'){ $op = substr($regs[8],0,1); @@ -1267,7 +1270,7 @@ class nusoap_xmlschema extends nusoap_base { if(count($attrs) > 0){ foreach($attrs as $k => $v){ // if ns declarations, add to class level array of valid namespaces - if(ereg("^xmlns",$k)){ + if(preg_match('/^xmlns/',$k)){ //$this->xdebug("$k: $v"); //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); if($ns_prefix = substr(strrchr($k,':'),1)){ @@ -1379,7 +1382,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -1399,7 +1402,7 @@ class nusoap_xmlschema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // </sequence> // </complexType> - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -1809,7 +1812,7 @@ class nusoap_xmlschema extends nusoap_base { } elseif(isset($this->attributes[$type])){ $this->xdebug("in getTypeDef, found attribute $type"); return $this->attributes[$type]; - } elseif (ereg('_ContainedType$', $type)) { + } elseif (preg_match('/_ContainedType$/', $type)) { $this->xdebug("in getTypeDef, have an untyped element $type"); $typeDef['typeClass'] = 'simpleType'; $typeDef['phpType'] = 'scalar'; @@ -2173,7 +2176,7 @@ class soap_transport_http extends nusoap_base { $this->ch_options = $curl_options; } $this->use_curl = $use_curl; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); } @@ -2936,7 +2939,7 @@ class soap_transport_http extends nusoap_base { } } // remove 100 headers - if (isset($lb) && ereg('^HTTP/1.1 100',$data)) { + if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) { unset($lb); $data = ''; }// @@ -3102,7 +3105,7 @@ class soap_transport_http extends nusoap_base { if ($data == '') { // have nothing left; just remove 100 header(s) $data = $savedata; - while (ereg('^HTTP/1.1 100',$data)) { + while (preg_match('/^HTTP\/1.1 100/',$data)) { if ($pos = strpos($data,"\r\n\r\n")) { $data = ltrim(substr($data,$pos)); } elseif($pos = strpos($data,"\n\n") ) { @@ -3654,7 +3657,7 @@ class nusoap_server extends nusoap_base { } $this->debug("In service, query string=$qs"); - if (ereg('wsdl', $qs) ){ + if (preg_match('/wsdl/', $qs) ){ $this->debug("In service, this is a request for WSDL"); if($this->externalWSDLURL){ if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL @@ -3725,7 +3728,7 @@ class nusoap_server extends nusoap_base { // get the character encoding of the incoming request if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){ $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1)); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -3754,7 +3757,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -3788,7 +3791,7 @@ class nusoap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -4018,7 +4021,7 @@ 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'))) { + if (isset($this->methodreturn) && ((get_class((object)$this->methodreturn) == 'soap_fault') || (get_class((object)$this->methodreturn) == 'nusoap_fault'))) { $this->debug('got a fault object from method'); $this->fault = $this->methodreturn; return; @@ -4126,7 +4129,7 @@ class nusoap_server extends nusoap_base { $payload .= $this->getDebugAsXMLComment(); } $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")"; // Let the Web server decide about this //$this->outgoing_headers[] = "Connection: Close\r\n"; @@ -4214,7 +4217,7 @@ class nusoap_server extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -4781,7 +4784,7 @@ class wsdl extends nusoap_base { $this->currentSchema->schemaStartElement($parser, $name, $attrs); $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); - } elseif (ereg('schema$', $name)) { + } elseif (preg_match('/schema$/', $name)) { $this->debug('Parsing WSDL schema'); // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); $this->status = 'schema'; @@ -4800,7 +4803,7 @@ class wsdl extends nusoap_base { if (count($attrs) > 0) { // register namespace declarations foreach($attrs as $k => $v) { - if (ereg("^xmlns", $k)) { + if (preg_match('/^xmlns/',$k)) { if ($ns_prefix = substr(strrchr($k, ':'), 1)) { $this->namespaces[$ns_prefix] = $v; } else { @@ -4825,7 +4828,7 @@ class wsdl extends nusoap_base { $attrs = array(); } // get element prefix, namespace and name - if (ereg(':', $name)) { + if (preg_match('/:/', $name)) { // get ns prefix $prefix = substr($name, 0, strpos($name, ':')); // get ns @@ -4990,7 +4993,7 @@ class wsdl extends nusoap_base { */ function end_element($parser, $name){ // unset schema status - if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) { + if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { $this->status = ""; $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); @@ -6587,7 +6590,7 @@ class nusoap_parser extends nusoap_base { $key_localpart = $this->getLocalPart($key); // if ns declarations, add to class level array of valid namespaces if($key_prefix == 'xmlns'){ - if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){ + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ $this->XMLSchemaVersion = $value; $this->namespaces['xsd'] = $this->XMLSchemaVersion; $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; @@ -6623,8 +6626,8 @@ class nusoap_parser extends nusoap_base { [5] length ::= nextDimension* Digit+ [6] nextDimension ::= Digit+ ',' */ - $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; - if(ereg($expr,$value,$regs)){ + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; + if(preg_match($expr,$value,$regs)){ $this->message[$pos]['typePrefix'] = $regs[1]; $this->message[$pos]['arrayTypePrefix'] = $regs[1]; if (isset($this->namespaces[$regs[1]])) { @@ -7422,7 +7425,7 @@ class nusoap_client extends nusoap_base { // detect transport switch(true){ // http(s) - case ereg('^http',$this->endpoint): + case preg_match('/^http/',$this->endpoint): $this->debug('transporting via HTTP'); if($this->persistentConnection == true && is_object($this->persistentConnection)){ $http =& $this->persistentConnection; @@ -7444,10 +7447,10 @@ class nusoap_client extends nusoap_base { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length='.strlen($msg)); - if(ereg('^http:',$this->endpoint)){ + if(preg_match('/^http:/',$this->endpoint)){ //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); - } elseif(ereg('^https',$this->endpoint)){ + } elseif(preg_match('/^https/',$this->endpoint)){ //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout,$response_timeout); @@ -7506,7 +7509,7 @@ class nusoap_client extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; -- 1.6.4.msysgit.0 | ||||
Patch against current git master ( 2aef5d9f83dcad6f51d7623982f9a1830d771c7d ) attached. |
|
added a patch (0001-php-5.3-support-for-the-soap-interface.patch) that replace ereg to preg_match in all NuSoap interface and cast in object for get_class. This patch is from 1.2.0rc2 source |
|
A lot of the fixes here are against NuSoap. I would hate to diverge from the official release. However, looking at the project, it seems that the last commit is about two years ago. http://sourceforge.net/projects/nusoap/ We have two options:
|
|
for version 1.2 continue to use NuSoap, but for long term, PHP Soap Extension is a good choice for support and compatibility. NuSoap seems to be dead, even if it's a good project. I wait for an answer from them. |
|
@rombert, can you please evaluate your patch and the patch provided by @calimero100582 and provide a pull request? @calimero100582, my issue with the soap extension is mainly around the fact that it is not enabled by default. |
|
Sure. I'll apply , test and issue the request in 3-4 days. |
|
yeah I already know that it is not installed (I don't have it on my server), but for me it is the best choice to avoid future problem. My patch is not 100% from me as I am not a regex expert, I use a patch from typo3 to complete all the regex I was not sure. Here is a link: http://bugs.typo3.org/view.php?id=9994 |
|
Just for the record, I've spent some time recently looking at replacing both the db api stuff I've come up with and also the nusoap stuff, with the approach that moodle uses (moodle used to use adodb but is slowly moving away from it) Paul |
|
@calimero100582 : I've tried to apply your patch and failed. <pre>error: patch failed: api/soap/mantisconnect.php:1356 Would it be possible to rebase your patch against the current master? Some fixes were applied in 387428137faed6d4dcb703122ede296fe002f101 , so most likely you'll drop your fixes against api/soap/mantisconnect.php and keep those against library/nusoap . |
|
just create a new patch that apply on 387428137faed6d4dcb703122ede296fe002f101. also work on master |
|
Looks good overall. I'll set up a VM for PHP 5.3 and get back to you. |
|
I see 2 changes similar to:
What is the reason behind these? |
|
in class.soap_server.php there is preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); if I only use "var $revision = '$Revision$';" there is nothing after Revision and then $rev[1] is null and the second line crash |
|
I've finally got around to running the tests, and I'm afraid they fail: pre>robert@neghvar:~/public_html/mantisbt/tests phpunit --bootstrap bootstrap.php AllTests.php Time: 48 seconds There were 9 errors: 1) testAccessLevel(EnumTest) The other 8 errors are similar. Please note that they only fail on PHP 5.3. |
|
you have to cast as object like get_class((object)$this->methodreturn) |
|
That is contained in your patch, and that's what I applied. Please review the nusoap_php53 branch at http://github.com/rombert/mantisbt . Perhaps I missed something. |
|
I correct the case that occurs to me. Send me your list error and I will correct them the current case is mc_enum_api.php Line 169 replace
|
|
@calimero100582 : that was the only issue left. Patches now committed to master and master-1.2.x. Thanks for the patch and for the patience. |
|
No problem, I'm happy to help |
|