Prevents error when updating taxomy collections list if a taxonomy is removed.

This commit is contained in:
mateuswetah 2023-11-29 21:42:44 -03:00
parent aa7b442079
commit c55e79cedc
1 changed files with 12 additions and 6 deletions

View File

@ -295,8 +295,11 @@ class Taxonomies extends Repository {
$id = $taxonomy_id;
if ( ! empty( $id ) && is_numeric( $id ) && is_numeric($collection_id) ) {
$tax = $this->fetch( (int) $id );
if ( $tax instanceof Entities\Taxonomy ) {
$tax->add_collection_id( $collection_id );
if ( $tax->validate() ) {
if ( $tax->validate() )
$this->insert( $tax );
}
}
@ -307,8 +310,11 @@ class Taxonomies extends Repository {
$id = $taxonomy_id;
if ( ! empty( $id ) && is_numeric( $id ) && is_numeric($collection_id) ) {
$tax = $this->fetch( (int) $id );
if ( $tax instanceof Entities\Taxonomy ) {
$tax->remove_collection_id( $collection_id );
if ( $tax->validate() ) {
if ( $tax->validate() )
$this->insert( $tax );
}
}