Skip to content

Commit

Permalink
Fixes issue related to list filter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstandiford committed Nov 20, 2022
1 parent d35b697 commit 0225ab5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/Helpers/Processors/List_Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,17 @@ protected function filter_item( object $item, ): ?object {
* @return array
*/
protected function filter_item_keys(): array {
$items = $this->items;
$items = array_keys($this->items);

// Filter out keys, if keys are specified
if ( isset( $this->filter_args[ Filter::in->key() ] ) ) {
$items = Array_Helper::intersect( array_keys( $this->items ), $this->filter_args[ Filter::in->key() ] );
$items = Array_Helper::intersect( $items, $this->filter_args[ Filter::in->key() ] );
unset( $this->filter_args[ Filter::in->key() ] );
}

if ( isset( $this->filter_args[ Filter::not_in->key() ] ) ) {
$items = Array_Helper::diff( array_keys( $this->items ), $this->filter_args[ Filter::not_in->key() ] );
$items = Array_Helper::diff( $items, $this->filter_args[ Filter::not_in->key() ] );
unset( $this->filter_args[ Filter::not_in->key() ] );
}

return $items;
Expand All @@ -122,7 +123,7 @@ protected function filter_item_keys(): array {
* @return ?object loader item if found.
*/
public function find(): ?object {
foreach ( $this->filter_item_keys() as $item_key => $item ) {
foreach ( $this->filter_item_keys() as $item_key ) {
if ( ! isset( $this->items[ $item_key ] ) ) {
continue;
}
Expand All @@ -145,7 +146,7 @@ public function find(): ?object {
*/
public function filter(): array {
$results = [];
foreach ( $this->filter_item_keys() as $item_key => $item ) {
foreach ( $this->filter_item_keys() as $item_key ) {
if ( ! isset( $this->items[ $item_key ] ) ) {
continue;
}
Expand Down

0 comments on commit 0225ab5

Please sign in to comment.