From e90aa04189edff259bd24818fbbede1660300cba Mon Sep 17 00:00:00 2001 From: Sadok Date: Wed, 24 Sep 2014 15:45:25 +0200 Subject: [PATCH] Fix issue when trying to save multiple Records contain invalid data --- src/Phpforce/SoapClient/BulkSaver.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Phpforce/SoapClient/BulkSaver.php b/src/Phpforce/SoapClient/BulkSaver.php index b34a198..9b6f920 100644 --- a/src/Phpforce/SoapClient/BulkSaver.php +++ b/src/Phpforce/SoapClient/BulkSaver.php @@ -236,8 +236,9 @@ private function addBulkUpsertRecord($sObject, $objectType, $matchField) */ private function flushCreates($objectType) { - $result = $this->client->create($this->bulkCreateRecords[$objectType], $objectType); + $bulkCreateRecords = $this->bulkCreateRecords[$objectType]; $this->bulkCreateRecords[$objectType] = array(); + $result = $this->client->create($bulkCreateRecords, $objectType); return $result; } @@ -254,8 +255,8 @@ private function flushDeletes() $ids[] = $record->Id; } - $result = $this->client->delete($ids); $this->bulkDeleteRecords = array(); + $result = $this->client->delete($ids); return $result; } @@ -268,8 +269,9 @@ private function flushDeletes() */ private function flushUpdates($objectType) { - $result = $this->client->update($this->bulkUpdateRecords[$objectType], $objectType); + $bulkUpdateRecords = $this->bulkUpdateRecords[$objectType]; $this->bulkUpdateRecords[$objectType] = array(); + $result = $this->client->update($bulkUpdateRecords, $objectType); return $result; } @@ -282,11 +284,12 @@ private function flushUpdates($objectType) */ private function flushUpserts($objectType) { + $bulkUpsertRecords = $this->bulkUpsertRecords[$objectType]; + $this->bulkUpsertRecords[$objectType] = array(); $result = $this->client->upsert( $this->bulkUpsertMatchFields[$objectType], - $this->bulkUpsertRecords[$objectType], + $bulkUpsertRecords, $objectType); - $this->bulkUpsertRecords[$objectType] = array(); return $result; }