Checks for empty array before setting conditionals of repository metatada inside sections.

This commit is contained in:
mateuswetah 2022-09-05 10:50:15 -03:00
parent 396dbe549f
commit 3bd79116df
1 changed files with 11 additions and 10 deletions

View File

@ -381,8 +381,10 @@ class Metadata_Sections extends Repository {
$metadata_sections_ids = $this->fetch_ids();
$collection_metadata_sections_id = array_diff(array_map(function($el) {return $el->get_id();} , $this->fetch_by_collection($collection)), [\Tainacan\Entities\Metadata_Section::$default_section_slug]);
$args_exclude = array_merge(
array(
if ( empty($collection_metadata_sections_id) ) {
$not_post_ids = [];
} else {
$args_exclude = array(
'meta_query' => array(
'relation' => 'AND',
array(
@ -398,10 +400,11 @@ class Metadata_Sections extends Repository {
)
)
)
)
);
$list_exclude = $metadata_repository->fetch_by_collection($collection, $args_exclude);
$not_post_ids = array_map(function($el) { return $el->get_id(); }, $list_exclude);
);
$list_exclude = $metadata_repository->fetch_by_collection($collection, $args_exclude);
$not_post_ids = array_map(function($el) { return $el->get_id(); }, $list_exclude);
}
$args = array_merge(
$args,
@ -416,10 +419,8 @@ class Metadata_Sections extends Repository {
'compare' => '='
),
array(
array(
'key' => 'metadata_section_id',
'compare' => 'NOT EXISTS'
)
'key' => 'metadata_section_id',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'metadata_section_id',