From f281aac4c58184e81c44475fd1f5a3981555ad40 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Mon, 15 Feb 2021 12:28:40 -0300 Subject: [PATCH] fix: not enable log after updating control metadata --- src/classes/repositories/class-tainacan-repository.php | 7 +++++++ .../metadata-types/control/class-tainacan-control.php | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/classes/repositories/class-tainacan-repository.php b/src/classes/repositories/class-tainacan-repository.php index 22559212d..26a094e7c 100644 --- a/src/classes/repositories/class-tainacan-repository.php +++ b/src/classes/repositories/class-tainacan-repository.php @@ -46,6 +46,13 @@ abstract class Repository { $this->use_logs = true; } + /** + * Get if creation of logs while inserting and updating entities are enable + */ + public function get_enabled_logs() { + return $this->use_logs; + } + /** * Register hooks */ diff --git a/src/views/admin/components/metadata-types/control/class-tainacan-control.php b/src/views/admin/components/metadata-types/control/class-tainacan-control.php index 0c49afecf..3a634c8f1 100644 --- a/src/views/admin/components/metadata-types/control/class-tainacan-control.php +++ b/src/views/admin/components/metadata-types/control/class-tainacan-control.php @@ -25,6 +25,7 @@ class MetadataTypeControlHelper { static function update_control_metadatum( $item ) { if ( $item instanceof \Tainacan\Entities\Item ) { $item_metadata_repositories = \Tainacan\Repositories\Item_Metadata::get_instance(); + $enabled_logs = $item_metadata_repositories->get_enabled_logs(); $item_metadata_repositories->disable_logs(); $collection = $item->get_collection(); $args = [ @@ -68,7 +69,7 @@ class MetadataTypeControlHelper { $errors[] = $update_item_metadatum->get_errors(); } } - $item_metadata_repositories->enable_logs(); + if($enabled_logs) $item_metadata_repositories->enable_logs(); } } }