hyperized / hostfact

Unofficial implementation of the HostFact API v2 for Laravel 5
MIT License
16 stars 15 forks source link

Undefined index #18

Closed infinity-webdesigns closed 6 years ago

infinity-webdesigns commented 6 years ago

Sometimes when i go to my page i get the message undefined index debtor. Once i refresh the page the error is gone..

I get the error for line 46. Can you tell me what i do wrong?

schermafbeelding 2018-01-02 om 23 00 47
hyperized commented 6 years ago

@inifinity-webdesigns it means the $aDebtor array is empty. It's possible that the $this->debtor->list([]) command returns no results. You might want replace line 29 with a section like:

$this->debtors = $this->debtor->list([])
if(empty($this->debtors)) {
    throw new \Exception('No debtors returned by API');
}

to detect such an event, before you start processing the array. No such detection exists within the current implementation, as in many cases it's perfectly legit to have no results returned (like, in the case where there are in fact no Debtors)

infinity-webdesigns commented 6 years ago

@hyperized I do have debtors in my wefact administration. I had the same problem with invoices before but that got fixed once i loaded the invoices in the construct.

hyperized commented 6 years ago

@inifinity-webdesigns I'm not sure how I can help you, I will need some more information about this issue to debug, such as the output of the $this->debtor->list([]) when this issue occurs. Can you provide me with that?

infinity-webdesigns commented 6 years ago

@hyperized That is going to be difficult as the error doesn't always occur. It looks like it only occurs when the CMS is idle for a while.

hyperized commented 6 years ago

@inifinity-webdesigns It's going to be even more difficult for me to help you in this case.

I suggest you go ahead and log all the objects so when it does occur I can help you further.

infinity-webdesigns commented 6 years ago

@hyperized It's very difficult. sometimes it looks like the page is loading faster then the handling of the API call and therefor the array is empty.

hyperized commented 6 years ago

@inifinity-webdesigns Ok, so: I understand it's difficult, but I cannot help you without further information. I'm no magician. The only thing you could try is to increase the timeout from 20 to 30 seconds to give Wefact a little more time to reply (it might be slow!). If that doesn't work, please don't reply unless you have additional information, because I will then continue to close this issue :).

infinity-webdesigns commented 6 years ago

@hyperized setting the timeout to 15 instead of 10 seems to have fixed the problem. Thnx!