Skip to content

Instantly share code, notes, and snippets.

Created November 29, 2015 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6d20b14d0f5fedbc04ca to your computer and use it in GitHub Desktop.
Save anonymous/6d20b14d0f5fedbc04ca to your computer and use it in GitHub Desktop.
PHP7.0.0RC8 Soap Array Reference Bug
<?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