fix: not enable log after updating control metadata

This commit is contained in:
vnmedeiros 2021-02-15 12:28:40 -03:00
parent b3ad43acb9
commit f281aac4c5
2 changed files with 9 additions and 1 deletions

View File

@ -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
*/

View File

@ -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();
}
}
}