Created
November 29, 2015 04:15
-
-
Save anonymous/6d20b14d0f5fedbc04ca to your computer and use it in GitHub Desktop.
PHP7.0.0RC8 Soap Array Reference Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('soap.wsdl_cache_enabled', 0); | |
ini_set('display_errors', 1); | |
ini_set('error_reporting', E_ALL | E_STRICT); | |
class SoapClientFine extends SoapClient { | |
public function __call($name, $params) { | |
return parent::__call($name, $this->preArgs($params)); | |
} | |
protected function preArgs($params) { | |
// Only continue if arguments were given | |
if (!array_key_exists(0, $params)) { | |
return $params; | |
} | |
// Assign without reference is OK | |
$args = $params[0]; | |
return $params; | |
} | |
} | |
class SoapClientBroken extends SoapClientFine { | |
protected function preArgs($params) { | |
// Only continue if arguments were given | |
if (!array_key_exists(0, $params)) { | |
return $params; | |
} | |
// Assign with reference modifies the request! | |
$args =& $params[0]; | |
return $params; | |
} | |
} | |
echo "PHP Version: " . PHP_VERSION . "\n"; | |
$client = new SoapClientFine('http://api.rwaws.com/PropertyServices/SupportService.asmx?wsdl', ['trace' => true]); | |
$res = $client->GetSuburbsByLocationCountry(['LocationName' => 3000]); | |
$fineReq = $client->__getLastRequest(); | |
$client = new SoapClientBroken('http://api.rwaws.com/PropertyServices/SupportService.asmx?wsdl', ['trace' => true]); | |
$res = $client->GetSuburbsByLocationCountry(['LocationName' => 3000]); | |
$badReq = $client->__getLastRequest(); | |
echo $fineReq == $badReq ? "PASS: Requests Identical\n" : "FAIL: Requests Differ\n"; | |
echo "Fine: $fineReq"; | |
echo "Bad: $badReq"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment