Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array key references break argument processing #2

Merged
merged 1 commit into from
Jan 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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