Merge branch 'develop' into feature/794

This commit is contained in:
mateuswetah 2024-03-13 12:24:52 -03:00
commit b148cc7f83
15 changed files with 246 additions and 48 deletions

View File

@ -1,3 +1,4 @@
# to run localy ./bin/act -j test
name: Tainacan tests
on:
@ -23,7 +24,7 @@ jobs:
matrix:
# Notes regarding supported versions in WP:
# The base matrix only contains the PHP versions which are supported on all supported WP versions.
php: ['7.3', '7.4', '8.3']
php: ['7.4', '8.3']
wp: ['latest', '5.9']
experimental: [false]
@ -50,7 +51,7 @@ jobs:
# in combination with PHP < 7.4 is not properly/sufficiently supported
# within WP Core.
# See: https://core.trac.wordpress.org/ticket/52496
image: mysql:${{ ( matrix.wp == 5.3 && '5.6' ) || ( (matrix.wp < 5.9 || matrix.php < 7.4) && '5.7' ) || '8.0' }}
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
ports:
@ -72,6 +73,9 @@ jobs:
- name: Check PHP Version
run: php -v
- name: install tools deps
run: sudo apt install mariadb-client -y
- name: Add bootstrap-config
run: |
mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php
@ -90,29 +94,18 @@ jobs:
- name: Determine supported PHPUnit version
id: set_phpunit
run: |
if [[ "${{ matrix.php }}" = "8.0" ]]; then
wget https://phar.phpunit.de/phpunit-9.3.0.phar -P /tmp
chmod +x /tmp/phpunit-9.3.0.phar
mv /tmp/phpunit-9.3.0.phar /usr/local/bin/phpunit
elif [[ "${{ matrix.php }}" > "6.0" ]]; then
if [[ "${{ matrix.php }}" > "8.0" ]]; then
wget https://phar.phpunit.de/phpunit-9.6.16.phar -P /tmp
chmod +x /tmp/phpunit-9.6.16.phar
mv /tmp/phpunit-9.6.16.phar /usr/local/bin/phpunit
else
wget https://phar.phpunit.de/phpunit-6.5.7.phar -P /tmp
chmod +x /tmp/phpunit-6.5.7.phar
mv /tmp/phpunit-6.5.7.phar /usr/local/bin/phpunit
else
wget https://phar.phpunit.de/phpunit-5.phar -P /tmp
chmod +x /tmp/phpunit-5.phar
mv /tmp/phpunit-5.phar /usr/local/bin/phpunit
fi
# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies for PHP < 7.3
if: ${{ matrix.php < 7.3 }}
uses: "ramsey/composer-install@v1"
with:
composer-options: --ignore-platform-reqs
dependency-versions: "lowest"
- name: Install Composer dependencies for PHP < 8.0
if: ${{ matrix.php >= 7.3 && matrix.php < 8.0 }}
uses: "ramsey/composer-install@v1"

169
package-lock.json generated
View File

@ -1351,9 +1351,9 @@
}
},
"@babel/traverse": {
"version": "7.23.7",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.7.tgz",
"integrity": "sha512-tY3mM8rH9jM0YHFGyfC0/xf+SB5eKUu7HPj7/k3fpi9dAlsMc5YbQvDi0Sh2QTPXqMhyaAtzAr807TIyfQrmyg==",
"version": "7.23.9",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.9.tgz",
"integrity": "sha512-I/4UJ9vs90OkBtY6iiiTORVMyIhJ4kAVmsKo9KFc8UOxMeUfi2hvtIBsET5u9GizXE6/GFSuKCTNfgCswuEjRg==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.23.5",
@ -1362,10 +1362,169 @@
"@babel/helper-function-name": "^7.23.0",
"@babel/helper-hoist-variables": "^7.22.5",
"@babel/helper-split-export-declaration": "^7.22.6",
"@babel/parser": "^7.23.6",
"@babel/types": "^7.23.6",
"@babel/parser": "^7.23.9",
"@babel/types": "^7.23.9",
"debug": "^4.3.1",
"globals": "^11.1.0"
},
"dependencies": {
"@babel/code-frame": {
"version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz",
"integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==",
"dev": true,
"requires": {
"@babel/highlight": "^7.23.4",
"chalk": "^2.4.2"
}
},
"@babel/generator": {
"version": "7.23.6",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.6.tgz",
"integrity": "sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw==",
"dev": true,
"requires": {
"@babel/types": "^7.23.6",
"@jridgewell/gen-mapping": "^0.3.2",
"@jridgewell/trace-mapping": "^0.3.17",
"jsesc": "^2.5.1"
}
},
"@babel/helper-environment-visitor": {
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz",
"integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==",
"dev": true
},
"@babel/helper-function-name": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz",
"integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==",
"dev": true,
"requires": {
"@babel/template": "^7.22.15",
"@babel/types": "^7.23.0"
}
},
"@babel/helper-hoist-variables": {
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz",
"integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==",
"dev": true,
"requires": {
"@babel/types": "^7.22.5"
}
},
"@babel/helper-split-export-declaration": {
"version": "7.22.6",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz",
"integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==",
"dev": true,
"requires": {
"@babel/types": "^7.22.5"
}
},
"@babel/helper-string-parser": {
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz",
"integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==",
"dev": true
},
"@babel/helper-validator-identifier": {
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
"integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
"dev": true
},
"@babel/highlight": {
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz",
"integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==",
"dev": true,
"requires": {
"@babel/helper-validator-identifier": "^7.22.20",
"chalk": "^2.4.2",
"js-tokens": "^4.0.0"
}
},
"@babel/parser": {
"version": "7.23.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.9.tgz",
"integrity": "sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA==",
"dev": true
},
"@babel/template": {
"version": "7.23.9",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.23.9.tgz",
"integrity": "sha512-+xrD2BWLpvHKNmX2QbpdpsBaWnRxahMwJjO+KZk2JOElj5nSmKezyS1B4u+QbHMTX69t4ukm6hh9lsYQ7GHCKA==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.23.5",
"@babel/parser": "^7.23.9",
"@babel/types": "^7.23.9"
}
},
"@babel/types": {
"version": "7.23.9",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.9.tgz",
"integrity": "sha512-dQjSq/7HaSjRM43FFGnv5keM2HsxpmyV1PfaSVm0nzzjwwTmjOe6J4bC8e3+pTEIgHaHj+1ZlLThRJ2auc/w1Q==",
"dev": true,
"requires": {
"@babel/helper-string-parser": "^7.23.4",
"@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0"
}
},
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
}
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
"dev": true
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
}
}
},
"@babel/types": {

View File

@ -249,8 +249,9 @@ class REST_Background_Processes_Controller extends REST_Controller {
}
public function prepare_item_for_response($item, $request) {
$item->log = $this->get_log_url($item->ID, $item->action);
$item->error_log = $this->get_log_url($item->ID, $item->action, 'error');
$key_log = $item->bg_uuid ?? $item->ID;
$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 = str_replace("&_wpnonce=[nonce]", "&_wpnonce=$nonce", $item->output);
return $item;

View File

@ -111,7 +111,7 @@ class REST_Exporters_Controller extends REST_Controller {
* @throws \Exception
*/
public function export_permissions_check($request) {
return true;
return current_user_can('manage_tainacan');
}
public function get_registered_exporters() {

View File

@ -137,7 +137,7 @@ class REST_Importers_Controller extends REST_Controller {
*/
public function import_permissions_check($request){
// TODO
return true;
return current_user_can('manage_tainacan');
}
/**

View File

@ -114,7 +114,8 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
'action' => $this->action,
'name' => $this->get_name(),
'queued_on' => date('Y-m-d H:i:s'),
'status' => 'waiting'
'status' => 'waiting',
'bg_uuid' => uniqid(),
]
);
$this->ID = $wpdb->insert_id;
@ -263,6 +264,7 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
$batch->key = $query->ID;
$batch->data = maybe_unserialize( $query->data );
$batch->status = $query->status;
$batch->bg_uuid = $query->bg_uuid;
if ($batch->status != 'running') {
$this->open($batch->key);
@ -271,6 +273,33 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
return $batch;
}
/**
* Get batch by key ID
*
* @return stdClass Return the batch
*/
protected function get_batch_by_key($key) {
global $wpdb;
$table = $this->table;
$query = $wpdb->get_row( $wpdb->prepare( "
SELECT *
FROM {$table}
WHERE action = %s
AND ID = %s
LIMIT 1
", $this->action, $key ) );
$batch = new \stdClass();
$batch->key = $query->ID;
$batch->data = maybe_unserialize( $query->data );
$batch->status = $query->status;
$batch->bg_uuid = $query->bg_uuid;
return $batch;
}
/**
* Handle
*
@ -428,10 +457,14 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
}
protected function write_log($key, $log) {
$this->write_log_to_file($key, $log);
$batch = $this->get_batch_by_key($key);
$key_log = $batch->bg_uuid ?? $key;
$this->write_log_to_file($key_log, $log);
}
protected function write_error_log($key, $log) {
$this->write_log_to_file($key, $log, 'error');
$batch = $this->get_batch_by_key($key);
$key_log = $batch->bg_uuid ?? $key;
$this->write_log_to_file($key_log, $log, 'error');
}
private function recursive_stingify_log_array(array $log, $break = true) {

View File

@ -695,7 +695,6 @@ abstract class Exporter {
$upload_dir_info = wp_upload_dir();
$prefix = $this->get_id();
$upload_dir = trailingslashit( $upload_dir_info['basedir'] );
// $upload_url = trailingslashit( $upload_dir_info['baseurl'] );
$exporter_folder = 'tainacan/exporter';
$file_suffix = "{$exporter_folder}/{$prefix}_{$key}";

View File

@ -507,7 +507,6 @@ class Migrations {
);
}
static function update_plugin_url_metadata_type_slug_to_core() {
global $wpdb;
// Brings plugin metadata type url to core
@ -521,6 +520,19 @@ class Migrations {
\deactivate_plugins( 'tainacan-url-metadata-type/tainacan-metadata-type-url.php' );
}
static function alter_table_tnc_bg_process_add_uuid() {
global $wpdb;
// update default order by "creation_date" to "date"
$table_name = $wpdb->prefix . 'tnc_bg_process';
$column_exists = $wpdb->get_results( "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '$table_name' AND column_name = 'bg_uuid'" );
if(empty($column_exists)) {
$wpdb->query("
ALTER TABLE $table_name
ADD bg_uuid text NULL
");
}
}
}
?>

View File

@ -1,21 +1,21 @@
=== Tainacan ===
Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros, tainacan, r-guimaraes, suelanesilva, ccaio, alanargomes, ateneagarcia123, rodrigo0freire, clarandreozzi
Tags: museums, libraries, archives, GLAM, collections, repository
Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros, tainacan, suelanesilva, ccaio, alanargomes, ateneagarcia123, rodrigo0freire, clarandreozzi
Tags: museums, archives, GLAM, collections, repository
Requires at least: 5.9
Tested up to: 6.4
Requires PHP: 7.0
Stable tag: 0.20.7
Stable tag: 0.20.8
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Tainacan is an open-source, powerful and flexible digital repository platform for WordPress. With all the tools of a professional repository platform, you can manage and publish your digital collections as easily as posting to your blog. It is versatile and can be used to create a digital collection, a digital library or a digital repository for your institutional or personal collection.
Tainacan is an open-source, powerful and flexible digital repository platform for WordPress.
== Description ==
[Tainacan](https://tainacan.org/) is an [open-source](https://github.com/tainacan/tainacan), powerful and flexible digital repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. It can be used for the creation of a digital collection, a digital library or a digital repository for your institutional or personal collection.
Tainacan aims to facilitate the activities of organizing, documenting, disseminating and displaying digital objects based on simple and accessible principles of digital curation. The plugin integrates with the WordPress block engine, making it easy to reuse objects for different and varied uses.
Tainacan aims to facilitate the activities of organizing, documenting, disseminating and displaying digital objects based on simple and accessible principles of digital curation. The plugin integrates with the WordPress block engine, making it easy to reuse objects for different and varied uses. You can manage and publish your digital collections as easily as posting to your blog. It is versatile and can be used to create a digital collection, a digital library or a digital repository for your institutional or personal collection.

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.
Author: Tainacan.org
Author URI: https://tainacan.org/
Version: 0.20.7
Version: 0.20.8
Requires at least: 5.9
Tested up to: 6.4
Requires PHP: 7.0
Stable tag: 0.20.7
Stable tag: 0.20.8
Text Domain: tainacan
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
const TAINACAN_VERSION = '0.20.7';
const TAINACAN_VERSION = '0.20.8';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -95,7 +95,7 @@
<span class="menu-text">{{ $i18n.get('capabilities') }}</span>
</router-link>
</li>
<li v-if="!$adminOptions.hidePrimaryMenuImportersButton">
<li v-if="!$adminOptions.hidePrimaryMenuImportersButton && $userCaps.hasCapability('manage_tainacan')">
<router-link
to="/importers"
:class="(
@ -109,7 +109,7 @@
<span class="menu-text menu-text-import">{{ $i18n.get('importers') }}</span>
</router-link>
</li>
<li v-if="!$adminOptions.hidePrimaryMenuExportersButton">
<li v-if="!$adminOptions.hidePrimaryMenuExportersButton && $userCaps.hasCapability('manage_tainacan')">
<router-link
to="/exporters"
:class="(

View File

@ -57,9 +57,8 @@
</h1>
<ul class="repository-subheader-icons">
<li>
<li v-if="!isRepositoryLevel && !$adminOptions.hideRepositorySubheaderExportButton && $userCaps.hasCapability('manage_tainacan')">
<a
v-if="!isRepositoryLevel && !$adminOptions.hideRepositorySubheaderExportButton"
id="exporter-collection-button"
class="button"
:aria-label="$i18n.get('exporters')"

View File

@ -82,7 +82,7 @@
<span class="menu-text">{{ $i18n.get('title_repository_activities_page') }}</span>
</router-link>
</li>
<li v-if="!$adminOptions.hideHomeImportersButton">
<li v-if="!$adminOptions.hideHomeImportersButton && $userCaps.hasCapability('manage_tainacan')">
<router-link
to="/importers">
<span class="icon is-medium">
@ -91,7 +91,7 @@
<span class="menu-text menu-text-import">{{ $i18n.get('importers') }}</span>
</router-link>
</li>
<li v-if="!$adminOptions.hideHomeExportersButton">
<li v-if="!$adminOptions.hideHomeExportersButton && $userCaps.hasCapability('manage_tainacan')">
<router-link
to="/exporters">
<span class="icon is-medium">

View File

@ -45,7 +45,9 @@
<small class="is-small">{{ $i18n.get('info_preset_collections') }}</small>
</div>
</b-dropdown-item>
<b-dropdown-item aria-role="listitem">
<b-dropdown-item
v-if="$userCaps.hasCapability('manage_tainacan')"
aria-role="listitem">
<div
id="a-import-collection"
tag="div"

View File

@ -203,7 +203,7 @@
</router-link>
</b-dropdown-item>
<b-dropdown-item
v-if="!$adminOptions.hideItemsListCreationDropdownImport"
v-if="!$adminOptions.hideItemsListCreationDropdownImport && $userCaps.hasCapability('manage_tainacan')"
aria-role="listitem">
<div
id="a-import-items"