Merge branch 'hotfix/0.21.1'

This commit is contained in:
vnmedeiros 2024-04-26 15:16:04 -03:00
commit 93e74e3f52
11 changed files with 27 additions and 15 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->log = $this->get_log_url($key_log, $item->action);
$item->error_log = $this->get_log_url($key_log, $item->action, 'error'); $item->error_log = $this->get_log_url($key_log, $item->action, 'error');
$nonce = wp_create_nonce( 'wp_rest' ); $nonce = wp_create_nonce( 'wp_rest' );
$item->output = $item->output ?? '';
$item->output = str_replace("&_wpnonce=[nonce]", "&_wpnonce=$nonce", $item->output); $item->output = str_replace("&_wpnonce=[nonce]", "&_wpnonce=$nonce", $item->output);
return $item; return $item;
} }
@ -376,14 +377,14 @@ class REST_Background_Processes_Controller extends REST_Controller {
$upload_url = wp_upload_dir(); $upload_url = wp_upload_dir();
$path = $upload_url['basedir'] . '/tainacan/' . $guid; $path = $upload_url['basedir'] . '/tainacan/' . $guid;
if ( file_exists( $path ) ) { if ( file_exists( $path ) ) {
$finfo = finfo_open(FILEINFO_MIME_TYPE); $finfo = @finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, $path); $mime_type = @finfo_file($finfo, $path);
$file_name = basename($path); $file_name = @basename($path);
http_response_code(200); http_response_code(200);
header('Content-Description: File Transfer'); header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename=$file_name"); header("Content-Disposition: attachment; filename=$file_name");
header("Content-Type: $mime_type"); header("Content-Type: $mime_type");
header("Content-Length: " . filesize( $path )); header("Content-Length: " . @filesize( $path ));
\readfile($path); \readfile($path);
} else { } else {
return new \WP_REST_Response("file not found", 404, array('content-type' => 'text/html; charset=utf-8')); 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('Shutdown with Fatal error captured');
$this->debug($error_str); $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->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Process aborted']]);
$this->close( $batch->key, 'errored' ); $this->close( $batch->key, 'errored' );
$this->debug('Batch closed due to captured error'); $this->debug('Batch closed due to captured error');
@ -363,7 +363,7 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
} catch (\Exception $e) { } catch (\Exception $e) {
// TODO: Add Stacktrace // TODO: Add Stacktrace
$this->debug('Fatal Error: ' . $e->getMessage()); $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']]); $this->write_error_log($batch->key, [['datetime' => date("Y-m-d H:i:s"), 'message' => 'Process aborted']]);
$task = false; $task = false;
$close_status = 'errored'; $close_status = 'errored';

View File

@ -721,6 +721,10 @@ abstract class Exporter {
public function append_to_file($key, $data) { public function append_to_file($key, $data) {
if ( array_key_exists ( $key , $this->output_files ) ) { if ( array_key_exists ( $key , $this->output_files ) ) {
$fp = fopen($this->output_files[$key]['filename'], 'a'); $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); fwrite($fp, $data);
fclose($fp); fclose($fp);
} else { // será? } 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 ); $terms = wp_get_object_terms( $item_metadata->get_item()->get_id(), $taxonomy_slug );
if( is_wp_error($terms) ) {
return null;
}
if ( $unique ) { if ( $unique ) {
$terms = reset( $terms ); $terms = reset( $terms );

View File

@ -4,7 +4,7 @@ Tags: museums, archives, GLAM, collections, repository
Requires at least: 5.9 Requires at least: 5.9
Tested up to: 6.5 Tested up to: 6.5
Requires PHP: 7.0 Requires PHP: 7.0
Stable tag: 0.21.0 Stable tag: 0.21.1
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@ -5,17 +5,17 @@ Plugin URI: https://tainacan.org/
Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform. Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform.
Author: Tainacan.org Author: Tainacan.org
Author URI: https://tainacan.org/ Author URI: https://tainacan.org/
Version: 0.21.0 Version: 0.21.1
Requires at least: 5.9 Requires at least: 5.9
Tested up to: 6.5 Tested up to: 6.5
Requires PHP: 7.0 Requires PHP: 7.0
Stable tag: 0.21.0 Stable tag: 0.21.1
Text Domain: tainacan Text Domain: tainacan
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/ */
const TAINACAN_VERSION = '0.21.0'; const TAINACAN_VERSION = '0.21.1';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__); $TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -682,7 +682,7 @@ export default {
if ( !$event.from.classList.contains('active-metadata-area') ) { if ( !$event.from.classList.contains('active-metadata-area') ) {
this.addNewMetadatum(this.getMetadatumTypes()[$event.oldIndex], $event.newIndex, sectionIndex); this.addNewMetadatum(this.getMetadatumTypes()[$event.oldIndex], $event.newIndex, sectionIndex);
$event.originalTarget.removeChild($event.item) $event.to.removeChild($event.item)
} else { } else {
this.isLoadingMetadataSections = true; this.isLoadingMetadataSections = true;
@ -698,7 +698,7 @@ export default {
newMetadataSectionsList[previousSectionIndex].metadata_object_list = previousSectionMetadataObjectList; newMetadataSectionsList[previousSectionIndex].metadata_object_list = previousSectionMetadataObjectList;
this.updateMetadataSections(newMetadataSectionsList); this.updateMetadataSections(newMetadataSectionsList);
$event.originalTarget.removeChild($event.item); $event.to.removeChild($event.item);
this.updateMetadatum({ this.updateMetadatum({
collectionId: this.collectionId, collectionId: this.collectionId,

View File

@ -371,7 +371,7 @@ export default {
case 'add': case 'add':
if ( !$event.from.classList.contains('active-metadata-area') ) { if ( !$event.from.classList.contains('active-metadata-area') ) {
this.addNewMetadatum(this.getMetadatumTypes()[$event.oldIndex], $event.newIndex); this.addNewMetadatum(this.getMetadatumTypes()[$event.oldIndex], $event.newIndex);
$event.originalTarget.removeChild($event.item); $event.to.removeChild($event.item);
} }
break; break;
case 'remove': case 'remove':

View File

@ -338,7 +338,7 @@
case 'add': case 'add':
if ( !$event.from.classList.contains('active-metadata-area') ) { if ( !$event.from.classList.contains('active-metadata-area') ) {
this.addNewMetadatum(this.getMetadatumTypes()[$event.oldIndex], $event.newIndex); this.addNewMetadatum(this.getMetadatumTypes()[$event.oldIndex], $event.newIndex);
$event.originalTarget.removeChild($event.item); $event.to.removeChild($event.item);
} }
break; break;
case 'remove': case 'remove':

View File

@ -304,6 +304,7 @@ html.is-clipped .page-container-small:not(.is-filters-menu-open) {
.taginput-container .input:hover { .taginput-container .input:hover {
border: none !important; border: none !important;
} }
.metadata-type-url .multivalue-separator,
.metadata-type-ainacan_url_plugin_metadata_type .multivalue-separator, .metadata-type-ainacan_url_plugin_metadata_type .multivalue-separator,
.metadata-type-tainacan_url_plugin_metadata_type .multivalue-separator { .metadata-type-tainacan_url_plugin_metadata_type .multivalue-separator {
display: block; display: block;
@ -314,10 +315,12 @@ html.is-clipped .page-container-small:not(.is-filters-menu-open) {
color: transparent !important; color: transparent !important;
margin: 1em auto 1em 0 !important; margin: 1em auto 1em 0 !important;
} }
.metadata-type-url .wp-block-buttons,
.metadata-type-ainacan_url_plugin_metadata_type .wp-block-buttons, .metadata-type-ainacan_url_plugin_metadata_type .wp-block-buttons,
.metadata-type-tainacan_url_plugin_metadata_type .wp-block-buttons { .metadata-type-tainacan_url_plugin_metadata_type .wp-block-buttons {
display: flex !important; display: flex !important;
} }
.metadata-type-url .wp-block-buttons>.wp-block-button,
.metadata-type-ainacan_url_plugin_metadata_type .wp-block-buttons>.wp-block-button, .metadata-type-ainacan_url_plugin_metadata_type .wp-block-buttons>.wp-block-button,
.metadata-type-tainacan_url_plugin_metadata_type .wp-block-buttons>.wp-block-button { .metadata-type-tainacan_url_plugin_metadata_type .wp-block-buttons>.wp-block-button {
width: auto !important; width: auto !important;

View File

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