From 266fd5645288f063d1f4f226caefec4cacfd771a Mon Sep 17 00:00:00 2001 From: Andrew Menich Date: Fri, 18 Aug 2023 16:38:39 -0400 Subject: [PATCH] replace is_iterable with is_array --- src/behaviors/SearchableBehavior.php | 6 +++--- src/console/controllers/scout/IndexController.php | 4 ++-- src/controllers/IndexController.php | 2 +- src/jobs/ImportIndex.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/behaviors/SearchableBehavior.php b/src/behaviors/SearchableBehavior.php index 1d825ba..d037074 100644 --- a/src/behaviors/SearchableBehavior.php +++ b/src/behaviors/SearchableBehavior.php @@ -39,7 +39,7 @@ class SearchableBehavior extends Behavior public function validatesCriteria(ScoutIndex $scoutIndex): bool { - if (is_iterable($scoutIndex->criteria)) { + if (is_array($scoutIndex->criteria)) { foreach($scoutIndex->criteria as $query) { $criteria = clone $query; @@ -48,7 +48,7 @@ public function validatesCriteria(ScoutIndex $scoutIndex): bool } } return true; - + } else { $criteria = clone $scoutIndex->criteria; @@ -64,7 +64,7 @@ public function getIndices(): Collection ->getSettings() ->getIndices() ->filter(function (ScoutIndex $scoutIndex) { - if(is_iterable($scoutIndex->criteria)){ + if(is_array($scoutIndex->criteria)){ $criteriaSiteIds = collect($scoutIndex->criteria)->map(function($criteria){ return Arr::wrap($criteria->siteId); })->flatten()->unique()->values()->toArray(); diff --git a/src/console/controllers/scout/IndexController.php b/src/console/controllers/scout/IndexController.php index fc96574..1bcf138 100644 --- a/src/console/controllers/scout/IndexController.php +++ b/src/console/controllers/scout/IndexController.php @@ -62,12 +62,12 @@ public function actionImport($index = '') $this->stdout("Added ImportIndex job for '{$engine->scoutIndex->indexName}' to the queue".PHP_EOL, Console::FG_GREEN); } else { // check if $engine->scoutIndex->criteria is iterable - if (is_iterable($engine->scoutIndex->criteria)) { + if (is_array($engine->scoutIndex->criteria)) { // use array_reduce to get the count of elements $totalElements = array_reduce($engine->scoutIndex->criteria, function ($carry, $query) { return $carry + $query->count(); }, 0); - + foreach($engine->scoutIndex->criteria as $query) { $elementsUpdated = 0; $batch = $query->batch( diff --git a/src/controllers/IndexController.php b/src/controllers/IndexController.php index 1263fbe..e243eb6 100644 --- a/src/controllers/IndexController.php +++ b/src/controllers/IndexController.php @@ -45,7 +45,7 @@ public function actionImport() } // check if $engine->scoutIndex->criteria is iterable - if (is_iterable($engine->scoutIndex->criteria)) { + if (is_array($engine->scoutIndex->criteria)) { // use array_reduce to get the count of elements $elementsCount = array_reduce($engine->scoutIndex->criteria, function ($carry, $query) { return $carry + $query->count(); diff --git a/src/jobs/ImportIndex.php b/src/jobs/ImportIndex.php index 4b2b400..2e81e79 100644 --- a/src/jobs/ImportIndex.php +++ b/src/jobs/ImportIndex.php @@ -23,7 +23,7 @@ public function execute($queue): void } // check if $engine->scoutIndex->criteria is iterable - if (is_iterable($engine->scoutIndex->criteria)) { + if (is_array($engine->scoutIndex->criteria)) { // use array_reduce to get the count of elements $elementsCount = array_reduce($engine->scoutIndex->criteria, function ($carry, $query) { return $carry + $query->count();