Skip to content

Commit

Permalink
Merge pull request #2 from elidemayo/patch-1
Browse files Browse the repository at this point in the history
Array key references break argument processing. Thanks for your collaboration
  • Loading branch information
davispeixoto committed Jan 26, 2016
2 parents bdec77f + d9a983c commit 7364b8e
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 7364b8e

Please sign in to comment.