Skip to content

Commit

Permalink
Array key references break argument processing
Browse files Browse the repository at this point in the history
To prevent encountering the "Array key references break argument processing" (https://bugs.php.net/bug.php?id=70993) bug on PHP 7.0.1
Replaced all array key references.
  • Loading branch information
elidemayo committed Jan 26, 2016
1 parent bdec77f commit d9a983c
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function __construct()
*/
public function create($sObjects, $type)
{
foreach ($sObjects as &$sObject) {
$arg = [];
foreach ($sObjects as $sObject) {
// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1)
$xmlStr = '';
if (isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) {
Expand All @@ -66,16 +67,15 @@ public function create($sObjects, $type)
}
}

$sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);
$soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);

// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2)
if ($xmlStr != '') {
$sObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
$soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
$arg[] = $soapObject;
}

$arg = $sObjects;

return parent::_create(new SoapParam($arg, "sObjects"));
}

Expand All @@ -88,7 +88,9 @@ public function create($sObjects, $type)
*/
public function update($sObjects, $type, $assignment_header = null, $mru_header = null)
{
foreach ($sObjects as &$sObject) {
$arg = new stdClass;
$arg->sObjects = [];
foreach ($sObjects as $sObject) {
// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1)
$xmlStr = '';
if (isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) {
Expand All @@ -97,17 +99,15 @@ public function update($sObjects, $type, $assignment_header = null, $mru_header
}
}

$sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);
$soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);

// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2)
if ($xmlStr != '') {
$sObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
$soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
$arg->sObjects[] = $soapObject;
}

$arg = new stdClass;
$arg->sObjects = $sObjects;

return parent::_update($arg);
}

Expand All @@ -125,9 +125,10 @@ public function update($sObjects, $type, $assignment_header = null, $mru_header
public function upsert($ext_Id, $sObjects, $type = 'Contact')
{
$arg = new stdClass;
$arg->sObjects = [];
$arg->externalIDFieldName = new SoapVar($ext_Id, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');

foreach ($sObjects as &$sObject) {
foreach ($sObjects as $sObject) {
// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #1)
$xmlStr = '';
if (isset($sObject->fieldsToNull) && is_array($sObject->fieldsToNull)) {
Expand All @@ -136,16 +137,15 @@ public function upsert($ext_Id, $sObjects, $type = 'Contact')
}
}

$sObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);
$soapObject = new SoapVar($sObject, SOAP_ENC_OBJECT, $type, $this->namespace);

// FIX for fieldsToNull issue - allow array in fieldsToNull (STEP #2)
if ($xmlStr != '') {
$sObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
$soapObject->enc_value->fieldsToNull = new SoapVar(new SoapVar($xmlStr, XSD_ANYXML), SOAP_ENC_ARRAY);
}
$arg->sObjects[] = $soapObject;
}

$arg->sObjects = $sObjects;

return parent::_upsert($arg);
}

Expand Down

0 comments on commit d9a983c

Please sign in to comment.