When someone calls
$query->delete_item( $id );
it deletes the item and then deletes it from the cache. This is done calling
$this->clean_item_cache( $item ); (where $item is an object)
The problem is the clean_item_cache() method accepts an array of object items. There is a cast done here but it actually casts the object passed to an array, where each object attribute becomes an index (instead of ending up with an array of objects). That said, the if ( ! is_object( $item ) ) { test is always true (we are iterating over the attributes, not over objects as intended).
Possible Solutions
The possible solutions seem to be simple:
Changing
$this->clean_item_cache( $item ); to
$this->clean_item_cache( array( $item ) );
fixes the problem.
Changing
$items = (array) $items; to
if ( ! is_array( $items ) ) { $items = array( $items ); }
Please, let me know if this all makes sense and I'll be more than happy to open a PR. Thanks!
The Problem
When someone calls
$query->delete_item( $id );
it deletes the item and then deletes it from the cache. This is done calling$this->clean_item_cache( $item );
(where$item
is an object)The problem is the
clean_item_cache()
method accepts an array of object items. There is a cast done here but it actually casts the object passed to an array, where each object attribute becomes an index (instead of ending up with an array of objects). That said, theif ( ! is_object( $item ) ) {
test is always true (we are iterating over the attributes, not over objects as intended).Possible Solutions
The possible solutions seem to be simple:
Changing
$this->clean_item_cache( $item );
to$this->clean_item_cache( array( $item ) );
fixes the problem.Changing
$items = (array) $items;
toif ( ! is_array( $items ) ) { $items = array( $items ); }
Please, let me know if this all makes sense and I'll be more than happy to open a PR. Thanks!