diff --git a/application/src/Api/Adapter/AbstractEntityAdapter.php b/application/src/Api/Adapter/AbstractEntityAdapter.php index 7fcc24793..9bca79153 100644 --- a/application/src/Api/Adapter/AbstractEntityAdapter.php +++ b/application/src/Api/Adapter/AbstractEntityAdapter.php @@ -121,20 +121,21 @@ public function buildBaseQuery(QueryBuilder $qb, array $query) { if (isset($query['id'])) { $ids = $query['id']; - if (is_string($ids) || is_int($ids)) { + if (is_int($ids)) { + $ids = [(string) $ids]; + } elseif (is_string($ids)) { // Account for comma-delimited IDs. $ids = false === strpos($ids, ',') ? [$ids] : explode(',', $ids); - } elseif (!is_array($ids)) { + } elseif (is_array($ids)) { + $ids = array_map('strval', $ids); + } else { // This is an invalid ID. Set to an empty array. $ids = []; } // Exclude null and empty-string IDs. Previous resource-only version // used is_numeric, but we want this to be able to work for possible // string IDs also. - $ids = array_map('trim', $ids); - $ids = array_filter($ids, function ($id) { - return !($id === null || $id === ''); - }); + $ids = array_filter(array_map('trim', $ids), 'strlen'); if ($ids) { $qb->andWhere($qb->expr()->in( 'omeka_root.id', diff --git a/application/src/Form/Element/ArrayTextarea.php b/application/src/Form/Element/ArrayTextarea.php index 61414c2f2..16ec8f32a 100644 --- a/application/src/Form/Element/ArrayTextarea.php +++ b/application/src/Form/Element/ArrayTextarea.php @@ -121,7 +121,7 @@ protected function stringToList($string) */ protected function fixEndOfLine($string) { - return str_replace(["\r\n", "\n\r", "\r"], ["\n", "\n", "\n"], $string); + return str_replace(["\r\n", "\n\r", "\r"], ["\n", "\n", "\n"], (string) $string); } /** diff --git a/application/src/View/Helper/SearchFilters.php b/application/src/View/Helper/SearchFilters.php index 3928501d8..aa928dc94 100644 --- a/application/src/View/Helper/SearchFilters.php +++ b/application/src/View/Helper/SearchFilters.php @@ -218,16 +218,19 @@ public function __invoke($partialName = null, array $query = null) case 'id': $filterLabel = $translate('ID'); + // Avoid a deprecated issue, so convert ids as string. $ids = $value; - if (is_string($ids) || is_int($ids)) { - $ids = false === strpos($ids, ',') ? [$ids] : explode(',', $ids); - } elseif (!is_array($ids)) { + if (is_int($ids)) { + $ids = [(string) $ids]; + } elseif (is_string($ids)) { + $ids = strpos($ids, ',') === false ? [$ids] : explode(',', $ids); + } elseif (is_array($ids)) { + $ids = array_map('strval', $ids); + } else { $ids = []; } $ids = array_map('trim', $ids); - $ids = array_filter($ids, function ($id) { - return !($id === null || $id === ''); - }); + $ids = array_filter($ids, 'strlen'); $filters[$filterLabel][] = implode(', ', $ids); break; }