When purging if the response from Fastly API is not an array the following error is thrown:

count(): Parameter must be an array or an object that implements Countable Api.php:251 [warning]

Comments

kasperg created an issue. See original summary.

kasperg’s picture

Status: Active » Needs review
StatusFileSize
new1.12 KB

Here is a patch that adds additional type checking for the response. If it is not an array we treat is as an error.

vvuksan-fastly’s picture

Status: Needs review » Fixed

Commited.

vvuksan-fastly’s picture

Status: Fixed » Closed (fixed)
gg4’s picture

+++ b/src/Api.php
@@ -248,7 +248,7 @@ class Api {
+        if (is_array($result) && count($result) > 0) {

This is highly problematic.

$result is an object in this case, not an array.

This change should be reverted ASAP.

valic’s picture

StatusFileSize
new800 bytes

We could add check if is object and then convert it to array (I am using attached patch).

gg4’s picture

@valic this issue is marked as closed and the change has been reverted. It is probably best to create a new issue explaining the benefits of that approach and the problem it solves.