From d651594d4a0c97df1996abaf1a2994ce9f0f5519 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Fri, 26 Apr 2024 09:19:15 -0300 Subject: [PATCH 1/6] fix: some adjuts to avoid `NOTICE` and `WARNING` --- ...ass-tainacan-rest-background-processes-controller.php | 9 +++++---- src/classes/class-tainacan-background-process.php | 4 ++-- src/classes/exporter/class-tainacan-exporter.php | 4 ++++ .../repositories/class-tainacan-item-metadata.php | 4 ++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php b/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php index 2074195d1..0574b2e96 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php @@ -253,6 +253,7 @@ class REST_Background_Processes_Controller extends REST_Controller { $item->log = $this->get_log_url($key_log, $item->action); $item->error_log = $this->get_log_url($key_log, $item->action, 'error'); $nonce = wp_create_nonce( 'wp_rest' ); + $item->output = $item->output ?? ''; $item->output = str_replace("&_wpnonce=[nonce]", "&_wpnonce=$nonce", $item->output); return $item; } @@ -376,14 +377,14 @@ class REST_Background_Processes_Controller extends REST_Controller { $upload_url = wp_upload_dir(); $path = $upload_url['basedir'] . '/tainacan/' . $guid; if ( file_exists( $path ) ) { - $finfo = finfo_open(FILEINFO_MIME_TYPE); - $mime_type = finfo_file($finfo, $path); - $file_name = basename($path); + $finfo = @finfo_open(FILEINFO_MIME_TYPE); + $mime_type = @finfo_file($finfo, $path); + $file_name = @basename($path); http_response_code(200); header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=$file_name"); header("Content-Type: $mime_type"); - header("Content-Length: " . filesize( $path )); + header("Content-Length: " . @filesize( $path )); \readfile($path); } else { return new \WP_REST_Response("file not found", 404, array('content-type' => 'text/html; charset=utf-8')); diff --git a/src/classes/class-tainacan-background-process.php b/src/classes/class-tainacan-background-process.php index 1dfa5db38..1337ec5e6 100644 --- a/src/classes/class-tainacan-background-process.php +++ b/src/classes/class-tainacan-background-process.php @@ -347,7 +347,7 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process { $this->debug('Shutdown with Fatal error captured'); $this->debug($error_str); - $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Fatal Error: ' . $error_str]] ); + $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Fatal Error: see the server error log for more details']] ); $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Process aborted']]); $this->close( $batch->key, 'errored' ); $this->debug('Batch closed due to captured error'); @@ -363,7 +363,7 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process { } catch (\Exception $e) { // TODO: Add Stacktrace $this->debug('Fatal Error: ' . $e->getMessage()); - $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Try Fatal Error: ' . $e->getMessage()]]); + $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Try Fatal Error: see the server error log for more details']]); $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Process aborted']]); $task = false; $close_status = 'errored'; diff --git a/src/classes/exporter/class-tainacan-exporter.php b/src/classes/exporter/class-tainacan-exporter.php index 62dd95cd6..e7ca3c0ac 100644 --- a/src/classes/exporter/class-tainacan-exporter.php +++ b/src/classes/exporter/class-tainacan-exporter.php @@ -721,6 +721,10 @@ abstract class Exporter { public function append_to_file($key, $data) { if ( array_key_exists ( $key , $this->output_files ) ) { $fp = fopen($this->output_files[$key]['filename'], 'a'); + if($fp == false) { + $file_name = $this->output_files[$key]['filename']; + throw new \Exception("Cannot open file $file_name"); + } fwrite($fp, $data); fclose($fp); } else { // serĂ¡? diff --git a/src/classes/repositories/class-tainacan-item-metadata.php b/src/classes/repositories/class-tainacan-item-metadata.php index c4f2cd94c..2d418c8ab 100644 --- a/src/classes/repositories/class-tainacan-item-metadata.php +++ b/src/classes/repositories/class-tainacan-item-metadata.php @@ -372,6 +372,10 @@ class Item_Metadata extends Repository { $terms = wp_get_object_terms( $item_metadata->get_item()->get_id(), $taxonomy_slug ); + if( is_wp_error($terms) ) { + return null; + } + if ( $unique ) { $terms = reset( $terms ); From d9cb515624fff75900a9fac8086ea5cf5d89adfe Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Fri, 26 Apr 2024 11:15:48 -0300 Subject: [PATCH 2/6] fix: tainacan plugin slug --- src/views/system-check/class-tainacan-system-check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/system-check/class-tainacan-system-check.php b/src/views/system-check/class-tainacan-system-check.php index 258cbe691..493146b54 100644 --- a/src/views/system-check/class-tainacan-system-check.php +++ b/src/views/system-check/class-tainacan-system-check.php @@ -538,7 +538,7 @@ class System_Check { $current_version = TAINACAN_VERSION; $args = array( - 'slug' => 'Tainacan', + 'slug' => 'tainacan', 'fields' => array( 'version' => true, ) From dc28f675f281d965321ea83bfff3578750e460fc Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Tue, 30 Apr 2024 14:46:30 -0300 Subject: [PATCH 3/6] Fixes item emtadata event handling on item submission form. --- .../gutenberg-blocks/blocks/item-submission-form/theme.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/gutenberg-blocks/blocks/item-submission-form/theme.vue b/src/views/gutenberg-blocks/blocks/item-submission-form/theme.vue index 7ecfa7a8d..519d35d4a 100644 --- a/src/views/gutenberg-blocks/blocks/item-submission-form/theme.vue +++ b/src/views/gutenberg-blocks/blocks/item-submission-form/theme.vue @@ -513,7 +513,7 @@ :help-info-bellow-label="helpInfoBellowLabel" :is-collapsed="metadataCollapses[index]" :enumerate-metadatum="metadataSections.length > 1 && collectionItemMetadataEnumeration === 'yes' ? ( (Number(sectionIndex) + 1) + '.' + (Number(getMetadatumOrderInSection(sectionIndex, itemMetadatum.metadatum)) + 1) ) : false" - @update:model-value="updateItemMetadataValue" + @input="updateItemMetadataValue" @change-collapse="onChangeCollapse($event, index)" /> From 992f34d6b020a5ec475035c9e131c05d18953aab Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Tue, 30 Apr 2024 14:47:07 -0300 Subject: [PATCH 4/6] Fixes status update not working on bulk edition modal. --- src/views/admin/components/modals/bulk-edition-modal.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/admin/components/modals/bulk-edition-modal.vue b/src/views/admin/components/modals/bulk-edition-modal.vue index 510b24b65..c8ba88f33 100644 --- a/src/views/admin/components/modals/bulk-edition-modal.vue +++ b/src/views/admin/components/modals/bulk-edition-modal.vue @@ -128,7 +128,7 @@ :disabled="bulkEditionProcedures[criterion].isDone" class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last" :placeholder="$i18n.get('instruction_select_a_status2')" - @update:model-update:value="($event) => addToBulkEditionProcedures($event, 'newValue', criterion)"> + @update:model-value="($event) => addToBulkEditionProcedures($event, 'newValue', criterion)">