Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid argument supplied for foreach() in WeatherForecast.php on line 85 #100

Closed
DacotahHarvey opened this issue Feb 8, 2017 · 7 comments

Comments

@DacotahHarvey
Copy link

DacotahHarvey commented Feb 8, 2017

Hello!

This issue has randomly started popping up on our website starting yesterday (February 7th)
I'm not entirely sure what the issue is, although my assumption is that OpenWeatherMap is returning some invalid data and the Constructor is trying to access something that doesn't exist.

Could this be caused by us going over our Rate Limits?

I am looking for a quick solution that we can apply as it is happening in both our test environment and on our Production environment.

Thank you for any help you can provide!

Full error message provided:

Warning: Invalid argument supplied for foreach() in /ourProject/lib/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/WeatherForecast.php on line 85

Link to the line in question:

https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/master/Cmfcmf/OpenWeatherMap/WeatherForecast.php#L85

@cmfcmf
Copy link
Owner

cmfcmf commented Feb 8, 2017

Hey @DacotahHarvey

I'm not entirely sure what the issue is, although my assumption is that OpenWeatherMap is returning some invalid data and the Constructor is trying to access something that doesn't exist.

Sounds like it could be true. The OpenWeatherMap API does also sorts of crazy things 😕

Could this be caused by us going over our Rate Limits?

Maybe, I don't know, to be honest.

I am looking for a quick solution that we can apply as it is happening in both our test environment and on our Production environment.

It'd be great if you could provide the data OpenWeatherMap returns when such an error occurs. Please try logging the $url and result here: https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/v2.1.2/Cmfcmf/OpenWeatherMap.php#L393-L395

The correct fix most likely depends on the data the API returns on these failed requests.

@cmfcmf cmfcmf added this to the 2.x.x milestone Feb 8, 2017
@DacotahHarvey
Copy link
Author

DacotahHarvey commented Feb 8, 2017

Hey @cmfcmf,

Thanks for the reply. It might take me a day or two to have the time to do this, so I will let you know when I have the information.

I am also going to reach out to OpenWeatherMap and see if they can provide any more information.

Talk soon,
Thanks!

@DacotahHarvey
Copy link
Author

Hey @cmfcmf,

I put in the required checks to log the calls from OpenWeatherMap but the issue doesn't seem to be happening anymore.

I am going to chalk it up to a period of bad data from the API.

Would you like me to close the issue?

Thanks for your help!

@peter279k
Copy link
Contributor

peter279k commented Feb 10, 2017

Hi @DacotahHarvey, I think this warning message about the $time is not valid for DateTime class constructor.
Maybe it gets some temporary error response json from the OpenWeatherAPI.....
Would you please use the var_dump or print_r to output the $time value?

Thanks.

@DacotahHarvey
Copy link
Author

Hey @peter279k,

Yes I can! Unfortunately it has been working perfectly again. Those two days seem to be the only times that something was acting up.

I will update this if I ever get another response with bad data :)

Thanks!

@cmfcmf
Copy link
Owner

cmfcmf commented Feb 13, 2017

Would you like me to close the issue?

I'm going to close this for now. Feel free to comment as soon as you experience these problems again! Will keep this in mind for version 3 (#72).

@cmfcmf cmfcmf closed this as completed Feb 13, 2017
@cmfcmf cmfcmf mentioned this issue Feb 13, 2017
21 tasks
@DacotahHarvey
Copy link
Author

@cmfcmf Thank you very much! I appreciate the consideration. I am glad this kind of fizzled out and resolved itself for the time being.

Thanks to both of you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants