From 4245d8dc55774612264ba87a0288a255ec013370 Mon Sep 17 00:00:00 2001 From: balexey88 Date: Thu, 27 Jun 2024 18:12:13 +0300 Subject: [PATCH] 4.0.4 maintenance release --- changelog.txt | 6 ++++++ changes.md | 6 ++++++ lib/classes/class-db.php | 2 +- lib/classes/class-sync-non-media.php | 16 ++++++++++------ lib/classes/class-utility.php | 16 ++++++++++------ lib/classes/status/class-info-stateless.php | 2 +- lib/classes/status/class-info.php | 13 ++++--------- readme.txt | 10 ++++++++-- static/scripts/wp-stateless-settings.js | 10 +++++++++- static/styles/wp-stateless-status.css | 8 ++++++++ static/views/status-sections/info.php | 8 ++++++-- wp-stateless-media.php | 2 +- 12 files changed, 70 insertions(+), 29 deletions(-) diff --git a/changelog.txt b/changelog.txt index 8a0e6f0b4..6a10de348 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,10 @@ == Changelog == += 4.0.4 = +* ENHANCEMENT - display success message after copying Status Info. +* FIX - `Settings` page does not open or slow when there is big amount of attachments. +* FIX - in multisite network, removing custom tables properly when deleting site. +* FIX - skip setting ACL in Stateless mode and during Sync for the buckets with Uniform access, support WP_STATELESS_SKIP_ACL_SET constant [#712](https://github.com/udx/wp-stateless/issues/712). + = 4.0.3 = * NEW - added `Info` section to the `Status` tab on the Settings page, which contains the system info and the ability to copy report to clipboard. * ENHANCEMENT - added `Documentation` link on the Plugins page. diff --git a/changes.md b/changes.md index 3218024b9..9fba88a35 100644 --- a/changes.md +++ b/changes.md @@ -1,3 +1,9 @@ +#### 4.0.4 +* ENHANCEMENT - display success message after copying Status Info. +* FIX - `Settings` page does not open or slow when there is big amount of attachments. +* FIX - in multisite network, removing custom tables properly when deleting site. +* FIX - skip setting ACL in Stateless mode and during Sync for the buckets with Uniform access, support WP_STATELESS_SKIP_ACL_SET constant [#712](https://github.com/udx/wp-stateless/issues/712). + #### 4.0.3 * NEW - added `Info` section to the `Status` tab on the Settings page, which contains the system info and the ability to copy report to clipboard. * ENHANCEMENT - added `Documentation` link on the Plugins page. diff --git a/lib/classes/class-db.php b/lib/classes/class-db.php index bf14bc361..ef610f45e 100644 --- a/lib/classes/class-db.php +++ b/lib/classes/class-db.php @@ -207,7 +207,7 @@ public function create_db() { * @param int $site_id */ public function clear_db($site_id) { - switch_to_blog($id); + switch_to_blog($site_id); $tables = array( $this->wpdb->prefix . 'files', diff --git a/lib/classes/class-sync-non-media.php b/lib/classes/class-sync-non-media.php index 9901aa18a..3831904de 100644 --- a/lib/classes/class-sync-non-media.php +++ b/lib/classes/class-sync-non-media.php @@ -142,12 +142,16 @@ public function sync_file($name, $absolutePath, $forced = false, $args = array() * @return media object */ try { - $media = $object->update(array('metadata' => $args['metadata']) + - array( - 'cacheControl' => apply_filters('sm:item:cacheControl', ud_get_stateless_media()->get_default_cache_control(), $absolutePath), - 'predefinedAcl' => 'publicRead', - 'contentDisposition' => apply_filters('sm:item:contentDisposition', null, $absolutePath) - )); + $mediaOptions = array( + 'cacheControl' => apply_filters('sm:item:cacheControl', ud_get_stateless_media()->get_default_cache_control(), $absolutePath), + 'contentDisposition' => apply_filters('sm:item:contentDisposition', null, $absolutePath) + ); + + if ( !defined('WP_STATELESS_SKIP_ACL_SET') || !WP_STATELESS_SKIP_ACL_SET) { + $mediaOptions['predefinedAcl'] = 'publicRead'; + } + + $media = $object->update(array('metadata' => $args['metadata']) + $mediaOptions); } catch (\Throwable $th) { //throw $th; } diff --git a/lib/classes/class-utility.php b/lib/classes/class-utility.php index fdc9b8098..1d3039866 100644 --- a/lib/classes/class-utility.php +++ b/lib/classes/class-utility.php @@ -326,12 +326,16 @@ public static function add_media($metadata, $attachment_id, $force = false, $arg * @return media object */ try { - $media = $object->update(array('metadata' => $media_args['metadata']) + - array( - 'cacheControl' => $_cacheControl, - 'predefinedAcl' => 'publicRead', - 'contentDisposition' => $_contentDisposition - )); + $mediaOptions = array( + 'cacheControl' => $_cacheControl, + 'contentDisposition' => $_contentDisposition + ); + + if ( !defined('WP_STATELESS_SKIP_ACL_SET') || !WP_STATELESS_SKIP_ACL_SET) { + $mediaOptions['predefinedAcl'] = 'publicRead'; + } + + $media = $object->update(array('metadata' => $media_args['metadata']) + $mediaOptions); $cloud_meta = self::generate_cloud_meta($cloud_meta, $media, $size, $img, $bucketLink); } catch (\Throwable $th) { diff --git a/lib/classes/status/class-info-stateless.php b/lib/classes/status/class-info-stateless.php index f03330cbf..2fe318895 100644 --- a/lib/classes/status/class-info-stateless.php +++ b/lib/classes/status/class-info-stateless.php @@ -2,7 +2,7 @@ /** * System Info (Stateless section) class * - * @since 4.1.0 + * @since 4.0.3 */ namespace wpCloud\StatelessMedia\Status; diff --git a/lib/classes/status/class-info.php b/lib/classes/status/class-info.php index 980e2039e..ccd6474b9 100644 --- a/lib/classes/status/class-info.php +++ b/lib/classes/status/class-info.php @@ -2,7 +2,7 @@ /** * System Info class * - * @since 4.1.0 + * @since 4.0.3 */ namespace wpCloud\StatelessMedia\Status; @@ -185,14 +185,9 @@ public function get_wordpress_attachments($values = []) { return $values; } - $query = new \WP_Query([ - 'post_type' => 'attachment', - 'post_status' => 'any', - 'posts_per_page' => -1, - ]); - - $total = $query->found_posts; - + global $wpdb; + $total = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'"); + $sizes = get_intermediate_image_sizes(); $rows = [ diff --git a/readme.txt b/readme.txt index ce727e019..d3ce1a8ad 100644 --- a/readme.txt +++ b/readme.txt @@ -5,8 +5,8 @@ Tags: google cloud, google cloud storage, cdn, uploads, backup License: GPLv2 or later Requires PHP: 8.0 Requires at least: 5.0 -Tested up to: 6.5.2 -Stable tag: 4.0.3 +Tested up to: 6.5.4 +Stable tag: 4.0.4 Upload and serve your WordPress media files from Google Cloud Storage. @@ -121,6 +121,12 @@ Before upgrading to WP-Stateless 3.2.0, please, make sure you use PHP 7.2 or abo Before upgrading to WP-Stateless 3.0, please, make sure you tested it on your development environment. == Changelog == += 4.0.4 = +* ENHANCEMENT - display success message after copying Status Info. +* FIX - `Settings` page does not open or slow when there is big amount of attachments. +* FIX - in multisite network, removing custom tables properly when deleting site. +* FIX - skip setting ACL in Stateless mode and during Sync for the buckets with Uniform access, support WP_STATELESS_SKIP_ACL_SET constant [#712](https://github.com/udx/wp-stateless/issues/712). + = 4.0.3 = * NEW - added `Info` section to the `Status` tab on the Settings page, which contains the system info and the ability to copy report to clipboard. * ENHANCEMENT - added `Documentation` link on the Plugins page. diff --git a/static/scripts/wp-stateless-settings.js b/static/scripts/wp-stateless-settings.js index 9fd71ecfc..887ae2a7a 100644 --- a/static/scripts/wp-stateless-settings.js +++ b/static/scripts/wp-stateless-settings.js @@ -55,5 +55,13 @@ jQuery(document).ready(function ($) { } }) - new ClipboardJS('.stateless-info-heading .copy-button'); + var clipboard = new ClipboardJS('.stateless-info-heading .copy-button') + + clipboard.on('success', function(e) { + $('.stateless-info-copy-success').show(); + + setTimeout(function() { + $('.stateless-info-copy-success').fadeOut(500); + }, 5000); + }) }) diff --git a/static/styles/wp-stateless-status.css b/static/styles/wp-stateless-status.css index 94b5077ee..17a803794 100644 --- a/static/styles/wp-stateless-status.css +++ b/static/styles/wp-stateless-status.css @@ -26,6 +26,14 @@ font-weight: 400; } +.stateless-info-copy-success { + line-height: 30px; + margin-right: 5px; + color: #007017; + font-weight: normal; + display: none; +} + /* Info table */ #stateless-info { border: 1px solid #c3c4c7; diff --git a/static/views/status-sections/info.php b/static/views/status-sections/info.php index 559c8f901..63e74a78a 100644 --- a/static/views/status-sections/info.php +++ b/static/views/status-sections/info.php @@ -2,8 +2,12 @@

- domain); ?> -

+ domain); ?> +
+ domain); ?> + +
+
diff --git a/wp-stateless-media.php b/wp-stateless-media.php index 3cb1299cd..eb19e1dae 100644 --- a/wp-stateless-media.php +++ b/wp-stateless-media.php @@ -4,7 +4,7 @@ * Plugin URI: https://stateless.udx.io/ * Description: Upload and serve your WordPress media files from Google Cloud Storage. * Author: UDX - * Version: 4.0.3 + * Version: 4.0.4 * Text Domain: stateless-media * Author URI: https://udx.io * License: GPLv2 or later