dotmailer / dotmailer-magento2-extension

The official Dotdigital for Magento2 extension
https://dotdigital.com/integrations/magento
MIT License
48 stars 63 forks source link

Fix "Notice: Undefined offset: 1" #508

Closed luklewluk closed 6 years ago

luklewluk commented 6 years ago

Hi.

On enabled strict PHP errors reporting I saw a following error on homepage:

Notice: Undefined offset: 1

Here's a fix for that. The reason of that was an invalid domain configuration in "API Endpoint Config".

To improve the fix I can also add a logging message like "Invalid API Endpoint Server". What do you think?

adeelq commented 6 years ago

Thanks @luklewluk. I'm reviewing your PR. Will update you soon.

adeelq commented 6 years ago

@luklewluk Can you please provide some details/steps on how i can replicate this.

If there was no endpoint returned from database it would return empty string https://github.com/dotmailer/dotmailer-magento2-extension/blob/master/Helper/Data.php#L1855

What $apiEndpoint value you got from https://github.com/dotmailer/dotmailer-magento2-extension/blob/master/Helper/Data.php#L1852

luklewluk commented 6 years ago

Hi @adeelq Thanks for reviewing. $apiEndpoint was api.dotmailer.test on my local because I replaced all .com to .test in my DB to prevent outgoing connections. So it's definitely an edge case scenario.

adeelq commented 6 years ago

@luklewluk You must have had this api.dotmailer.test.com saved in DB long before we introduced regions. Api endpoint is now in this format. https://REGION-NUMBER-api.dotmailer.com

I can see this a valid scenario to replicate this if you have api.dotmailer.test.com as apiEndpoint.