short-pixel-optimizer/shortpixel-php

Warning in Client.php

Closed this issue · 1 comments

At line 70 in Client.php there is often times a PHP-Warning "invalid argument supplied for foreeach"

The reason is that $body is not necessarly an array. actually $body is initialized with NULL when not suppplied to the function. It should be easily fixed with something like this:

<?php
if ($body) {
    foreach($body as $key => $val) {
        if($val === null) {
            unset($body[$key]);  
        }
    }
}

Thanks @csaggo for this. Fixed by commit 8ddbdda