From 20b56854a3ea00a801f0d5e209e40c51ea680626 Mon Sep 17 00:00:00 2001 From: Leo Germani Date: Fri, 1 Dec 2017 16:57:15 -0200 Subject: [PATCH] Fix fetch with empty args to return everything --- src/classes/repositories/class-tainacan-filters.php | 2 +- src/classes/repositories/class-tainacan-items.php | 8 +++++--- src/classes/repositories/class-tainacan-logs.php | 2 +- src/classes/repositories/class-tainacan-metadatas.php | 2 +- src/classes/repositories/class-tainacan-taxonomies.php | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/classes/repositories/class-tainacan-filters.php b/src/classes/repositories/class-tainacan-filters.php index c7762cce3..412bf994b 100644 --- a/src/classes/repositories/class-tainacan-filters.php +++ b/src/classes/repositories/class-tainacan-filters.php @@ -178,7 +178,7 @@ class Filters extends Repository { public function fetch($args = [], $output = null){ if( is_numeric($args) ){ return new Entities\Filter($args); - } elseif (!empty($args)) { + } elseif (is_array($args)) { // TODO: get filters from parent collections $args = array_merge([ 'posts_per_page' => -1, diff --git a/src/classes/repositories/class-tainacan-items.php b/src/classes/repositories/class-tainacan-items.php index b4f94c720..8e94cd785 100644 --- a/src/classes/repositories/class-tainacan-items.php +++ b/src/classes/repositories/class-tainacan-items.php @@ -61,9 +61,11 @@ class Items extends Repository { } // register taxonomies - foreach ($taxonomies as $taxonomy) { - $taxonomy->register_taxonomy(); - } + if (is_array($taxonomies) && sizeof($taxonomies) > 0) { + foreach ($taxonomies as $taxonomy) { + $taxonomy->register_taxonomy(); + } + } } public function insert($item) { diff --git a/src/classes/repositories/class-tainacan-logs.php b/src/classes/repositories/class-tainacan-logs.php index 2ee17163c..8a1f4f7d3 100644 --- a/src/classes/repositories/class-tainacan-logs.php +++ b/src/classes/repositories/class-tainacan-logs.php @@ -124,7 +124,7 @@ class Logs extends Repository { public function fetch($args = [], $output = null){ if(is_numeric($args)){ return new Entities\Log($args); - } else { + } elseif (is_array($args)) { $args = array_merge([ 'post_status' => 'publish', ], $args); diff --git a/src/classes/repositories/class-tainacan-metadatas.php b/src/classes/repositories/class-tainacan-metadatas.php index c1dae1124..8da6fe7c0 100644 --- a/src/classes/repositories/class-tainacan-metadatas.php +++ b/src/classes/repositories/class-tainacan-metadatas.php @@ -202,7 +202,7 @@ class Metadatas extends Repository { if( is_numeric($args) ){ return new Entities\Metadata($args); - } elseif (!empty($args)) { + } elseif (is_array($args)) { $args = array_merge([ 'posts_per_page' => -1, diff --git a/src/classes/repositories/class-tainacan-taxonomies.php b/src/classes/repositories/class-tainacan-taxonomies.php index 19c3b3f8e..538cd2489 100644 --- a/src/classes/repositories/class-tainacan-taxonomies.php +++ b/src/classes/repositories/class-tainacan-taxonomies.php @@ -163,7 +163,7 @@ class Taxonomies extends Repository { if( is_numeric($args) ){ return new Entities\Taxonomy($args); - } elseif (!empty($args)) { + } elseif (is_array($args)) { $args = array_merge([ 'posts_per_page' => -1,