Merge tag '0.21.1' into develop

release 0.21.1
This commit is contained in:
vnmedeiros 2024-04-26 15:16:16 -03:00
commit 82caa474ca
5 changed files with 16 additions and 7 deletions

View File

@ -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'));

View File

@ -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';

View File

@ -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á?

View File

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

View File

@ -538,7 +538,7 @@ class System_Check {
$current_version = TAINACAN_VERSION;
$args = array(
'slug' => 'Tainacan',
'slug' => 'tainacan',
'fields' => array(
'version' => true,
)