From e71ab9d769b1fff4230031b96933b396aac91924 Mon Sep 17 00:00:00 2001 From: Martin Butt Date: Mon, 23 Mar 2015 08:17:09 -0700 Subject: [PATCH 1/2] Chunk large delete requests --- soapclient/SforceBaseClient.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/soapclient/SforceBaseClient.php b/soapclient/SforceBaseClient.php index 3b494c7..0b98c65 100644 --- a/soapclient/SforceBaseClient.php +++ b/soapclient/SforceBaseClient.php @@ -578,9 +578,19 @@ public function convertLead($leadConverts) { */ public function delete($ids) { $this->setHeaders("delete"); - $arg = new stdClass(); - $arg->ids = $ids; - return $this->sforce->delete($arg)->result; + if(count($ids) > 200) { + $chunked_ids = array_chunk($ids, 200); + foreach($chunked_ids as $cids) { + $arg = new stdClass; + $arg->ids = $cids; + $result = $this->sforce->delete($arg)->result; + } + } else { + $arg = new stdClass; + $arg->ids = $ids; + $result = $this->sforce->delete($arg)->result; + } + return $result; } /** From 53025b4fda4e9805c6551bd4943ef3ae6392c77a Mon Sep 17 00:00:00 2001 From: Martin Butt Date: Mon, 23 Mar 2015 13:17:02 -0700 Subject: [PATCH 2/2] Merge the results of the chunked delete() --- soapclient/SforceBaseClient.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/soapclient/SforceBaseClient.php b/soapclient/SforceBaseClient.php index 0b98c65..4a59196 100644 --- a/soapclient/SforceBaseClient.php +++ b/soapclient/SforceBaseClient.php @@ -579,11 +579,12 @@ public function convertLead($leadConverts) { public function delete($ids) { $this->setHeaders("delete"); if(count($ids) > 200) { + $result = array(); $chunked_ids = array_chunk($ids, 200); foreach($chunked_ids as $cids) { $arg = new stdClass; $arg->ids = $cids; - $result = $this->sforce->delete($arg)->result; + $result = array_merge($result, $this->sforce->delete($arg)->result); } } else { $arg = new stdClass;