Skip to content

Commit

Permalink
applied fix to handle the more strict behaviour of property_exists() …
Browse files Browse the repository at this point in the history
…function in PHP >=8.0 when accidentally passing an array instead of an object
  • Loading branch information
malle-pietje committed Nov 24, 2024
1 parent 90af0f1 commit b8b8e16
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ajax/fetch_collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@

if (!empty($data_array)) {
/**
* Count the objects and inject $data_array into $results.
* Count the array items and inject $data_array into $results.
*/
$results['count'] = count($data_array);

/**
* For results returned from API v2, we need to check for the 'data' property and count that.
* For results returned from API v2, we need to check for the 'data' key and count items in that array.
*/
if(property_exists($data_array, 'data')) {
$results['count'] = count($data_array->data);
if(key_exists('data', $data_array)) {
$results['count'] = count($data_array['data']);
}

if ($debug) {
Expand Down

0 comments on commit b8b8e16

Please sign in to comment.