PHP Warning: Invalid argument supplied for foreach() in Image.php on line 155#23
Conversation
…ge::checkNumberOfAllowedFilters() when glob() returns false - Moved Image::checkNumberOfAllowedFilters() and Image::checkReferrer() calls into Image::setupFile() function - Removed duplicate code in Image::checkCache()
|
Thanks for this, I'll have a look now. |
|
This also fixes 404s on uncached images, if you set the option "numberOfAllowedFilters" to 1 (in the case where glob() returns false, because count(false) == 1). |
|
Hi Alexander, I haven't had the time to completely look at your pull request do to work commitments. I hope to get it all merged in this weekend :). Just wondering though, the return from glob(), can you not just check to make sure it's an array with |
That's exactly what I am doing :) (lines 157-159)
The other parts is more or less just refactoring (removing duplicate code, move filter checks out of "checkCache()" method, don't call "checkNumberOfAllowedFilters()" if there are filter requested). I'll annotate them. |
|
Well I feel silly now haha. I only had a very brief look ><. Okay well, I'll merge this in on the weekend. Thanks again! |
Haha don't feel silly! Thanks for having a look. I hope the annotations help you see my intentions for the changes. |
|
I've just went through it and these are great changes! Can't believe I didn't use I'm just going to merge these now and create a new release. Thanks a ton! Your pull requests are welcome any time 👍. |
…mages Fixing a PHP Warning: Invalid argument supplied for foreach() due to glob() sometimes returning false rather than an array. Plus some refactoring changes to remove duplicate code.
|
1.5.15 is now released :) - http://mun.ee/Changelog Thanks again! |
Requesting an image, which has not been cached yet, leads to a PHP warning:
This is because glob() may return false instead of an empty array which is then passed to foreach (leading to a warning):
Here's my pull request which fixes this warning: