Skip to content

Commit

Permalink
Merge pull request #65 from jnstr/fix-getAllCustomer
Browse files Browse the repository at this point in the history
Fix possible infinite loop for crmGetAllCustomers
  • Loading branch information
carakas authored Sep 29, 2017
2 parents a69e72f + fa7d0eb commit 8a1b0cd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Teamleader.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,11 @@ public function crmGetAllCustomers()
$customers['contacts'] = array();
$i = 0;
while ($i == 0 || (sizeof($customers['contacts']) != 0 && sizeof($customers['contacts']) % 100 == 0)) {
foreach ($this->crmGetContacts(100, $i) as $contact) {
$contacts = $this->crmGetContacts(100, $i);
if (empty($contacts)) {
break;
}
foreach ($contacts as $contact) {
$customers['contacts'][$contact->getId()] = $contact;
}
$i++;
Expand All @@ -756,7 +760,11 @@ public function crmGetAllCustomers()
$customers['companies'] = array();
$i = 0;
while ($i == 0 || (sizeof($customers['companies']) != 0 && sizeof($customers['companies']) % 100 == 0)) {
foreach ($this->crmGetCompanies(100, $i) as $company) {
$companies = $this->crmGetCompanies(100, $i);
if (empty($companies)) {
break;
}
foreach ($companies as $company) {
$customers['companies'][$company->getId()] = $company;
}
$i++;
Expand Down

0 comments on commit 8a1b0cd

Please sign in to comment.