diff --git a/README.md b/README.md index 5b67ae4a..ee9a2e32 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Requires at least:** 4.9 **Tested up to:** 5.9 **Requires PHP:** 5.6 -**Stable tag:** 2.6.0 +**Stable tag:** 2.6.1 **License:** GPLv3 Copies files to Amazon S3, DigitalOcean Spaces or Google Cloud Storage as they are uploaded to the Media Library. Optionally configure Amazon CloudFront or another CDN for faster delivery. @@ -93,6 +93,9 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin ## Changelog ## +### WP Offload Media Lite 2.6.1 - 2022-03-21 ### +* Bug fix: Local files are no longer removed if as3cf_pre_upload_attachment filter is used to abort upload + ### WP Offload Media Lite 2.6 - 2022-03-09 ### * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-6-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting) * New: WP Offload Media is now compatible with WordPress 5.9 and Full Site Editing diff --git a/classes/amazon-s3-and-cloudfront.php b/classes/amazon-s3-and-cloudfront.php index efb8a882..b7bfe9c4 100644 --- a/classes/amazon-s3-and-cloudfront.php +++ b/classes/amazon-s3-and-cloudfront.php @@ -26,6 +26,7 @@ use DeliciousBrains\WP_Offload_Media\Providers\Storage\GCP_Provider; use DeliciousBrains\WP_Offload_Media\Providers\Storage\Null_Provider; use DeliciousBrains\WP_Offload_Media\Providers\Storage\Storage_Provider; +use DeliciousBrains\WP_Offload_Media\Upgrades\Clear_Postmeta_Cache; use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade; use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade_Content_Replace_URLs; use DeliciousBrains\WP_Offload_Media\Upgrades\Upgrade_EDD_Replace_URLs; @@ -166,7 +167,7 @@ class Amazon_S3_And_CloudFront extends AS3CF_Plugin_Base { */ protected $integration_manager; - const LATEST_UPGRADE_ROUTINE = 10; + const LATEST_UPGRADE_ROUTINE = 11; /** * @param string $plugin_file_path @@ -231,6 +232,7 @@ public function init( $plugin_file_path ) { new Upgrade_Items_Table( $this ); new Upgrade_Tools_Errors( $this ); new Upgrade_Item_Extra_Data( $this ); + new Clear_Postmeta_Cache( $this ); // Plugin setup add_action( 'admin_menu', array( $this, 'admin_menu' ) ); diff --git a/classes/as3cf-filter.php b/classes/as3cf-filter.php index 6edad1f4..8024976f 100644 --- a/classes/as3cf-filter.php +++ b/classes/as3cf-filter.php @@ -441,7 +441,7 @@ protected function is_failure( $value ) { * @return bool */ public function item_matches_src( $item_source, $url ) { - if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) || Media_Library_Item::source_type() !== $item_source['source_type'] ) { + if ( Item::is_empty_item_source( $item_source ) || Media_Library_Item::source_type() !== $item_source['source_type'] ) { return false; } $meta = get_post_meta( $item_source['id'], '_wp_attachment_metadata', true ); @@ -533,7 +533,7 @@ protected function push_to_url_pairs( &$url_pairs, $item_source, $find, &$to_cac * @return null|string */ public function get_size_string_from_url( $item_source, $url ) { - if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) { + if ( Item::is_empty_item_source( $item_source ) ) { return false; } diff --git a/classes/filters/as3cf-local-to-s3.php b/classes/filters/as3cf-local-to-s3.php index 93d7d8c4..425cd115 100644 --- a/classes/filters/as3cf-local-to-s3.php +++ b/classes/filters/as3cf-local-to-s3.php @@ -183,7 +183,7 @@ public function url_needs_replacing( $url ) { * @return bool|string */ protected function get_url( $item_source, $object_key = null ) { - if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) { + if ( Item::is_empty_item_source( $item_source ) ) { return false; } @@ -207,7 +207,7 @@ protected function get_url( $item_source, $object_key = null ) { * @return string|false */ protected function get_base_url( $item_source ) { - if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) { + if ( Item::is_empty_item_source( $item_source ) ) { return false; } diff --git a/classes/filters/as3cf-s3-to-local.php b/classes/filters/as3cf-s3-to-local.php index ea8c1226..62a33524 100644 --- a/classes/filters/as3cf-s3-to-local.php +++ b/classes/filters/as3cf-s3-to-local.php @@ -110,7 +110,7 @@ public function url_needs_replacing( $url ) { * @return bool|string */ protected function get_url( $item_source, $object_key = null ) { - if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) { + if ( Item::is_empty_item_source( $item_source ) ) { return false; } @@ -134,7 +134,7 @@ protected function get_url( $item_source, $object_key = null ) { * @return string|false */ protected function get_base_url( $item_source ) { - if ( empty( $item_source['id'] ) || empty( $item_source['source_type'] ) ) { + if ( Item::is_empty_item_source( $item_source ) ) { return false; } @@ -155,7 +155,7 @@ protected function get_base_url( $item_source ) { * * @param string $url * - * @return bool|int + * @return bool|array */ public function get_item_source_from_url( $url ) { // Result for sized URL already cached in request, return it. @@ -165,7 +165,7 @@ public function get_item_source_from_url( $url ) { $item_source = Item::get_item_source_by_remote_url( $url ); - if ( ! empty( $item_source['id'] ) ) { + if ( ! Item::is_empty_item_source( $item_source ) ) { $this->query_cache[ $url ] = $item_source; return $item_source; @@ -187,7 +187,7 @@ public function get_item_source_from_url( $url ) { $item_source = Item::get_item_source_by_remote_url( $full_url ); - $this->query_cache[ $full_url ] = ! empty( $item_source['id'] ) ? $item_source : false; + $this->query_cache[ $full_url ] = ! Item::is_empty_item_source( $item_source ) ? $item_source : false; return $this->query_cache[ $full_url ]; } diff --git a/classes/integrations/core.php b/classes/integrations/core.php index 06f61f35..81e9f86d 100644 --- a/classes/integrations/core.php +++ b/classes/integrations/core.php @@ -34,7 +34,7 @@ public function init() { * @param array $options Handler dependent options that may have been set for the action. */ public function maybe_remove_local_files( $result, Item $as3cf_item, array $options ) { - if ( ! is_wp_error( $result ) && $this->as3cf->get_setting( 'remove-local-file', false ) && $as3cf_item->exists_locally() ) { + if ( ! is_wp_error( $result ) && $as3cf_item->id() && $this->as3cf->get_setting( 'remove-local-file', false ) && $as3cf_item->exists_locally() ) { $remove_local_handler = $this->as3cf->get_item_handler( Remove_Local_Handler::get_item_handler_key_name() ); $remove_local_handler->handle( $as3cf_item ); diff --git a/classes/integrations/media-library.php b/classes/integrations/media-library.php index 1bfaf5e6..5c8a876a 100644 --- a/classes/integrations/media-library.php +++ b/classes/integrations/media-library.php @@ -225,13 +225,7 @@ public function wp_update_attachment_metadata( $data, $post_id ) { */ protected function upload_item( Media_Library_Item $as3cf_item, array $offloaded_files ) { $upload_handler = $this->as3cf->get_item_handler( Upload_Handler::get_item_handler_key_name() ); - $upload_result = $upload_handler->handle( $as3cf_item, array( 'offloaded_files' => $offloaded_files ) ); - - if ( is_wp_error( $upload_result ) ) { - foreach ( $upload_result->get_error_messages() as $error_message ) { - AS3CF_Error::Log( $error_message ); - } - } + $upload_handler->handle( $as3cf_item, array( 'offloaded_files' => $offloaded_files ) ); } /** @@ -1124,7 +1118,7 @@ public function get_size_string_from_url_for_item_source( $size, $url, $item_sou public function get_attachment_id_from_provider_url( $url ) { $item_source = $this->as3cf->filter_provider->get_item_source_from_url( $url ); - if ( ! empty( $item_source['id'] ) && ! empty( $item_source['source_type'] ) && Media_Library_Item::source_type() === $item_source['source_type'] ) { + if ( ! Item::is_empty_item_source( $item_source ) && Media_Library_Item::source_type() === $item_source['source_type'] ) { return $item_source['id']; } @@ -1141,7 +1135,7 @@ public function get_attachment_id_from_provider_url( $url ) { public function get_attachment_id_from_local_url( $url ) { $item_source = $this->as3cf->filter_local->get_item_source_from_url( $url ); - if ( ! empty( $item_source['id'] ) && ! empty( $item_source['source_type'] ) && Media_Library_Item::source_type() === $item_source['source_type'] ) { + if ( ! Item::is_empty_item_source( $item_source ) && Media_Library_Item::source_type() === $item_source['source_type'] ) { return $item_source['id']; } diff --git a/classes/items/download-handler.php b/classes/items/download-handler.php index e823b217..9d02d5b4 100644 --- a/classes/items/download-handler.php +++ b/classes/items/download-handler.php @@ -2,7 +2,6 @@ namespace DeliciousBrains\WP_Offload_Media\Items; -use AS3CF_Error; use DeliciousBrains\WP_Offload_Media\Providers\Storage\Storage_Provider; use Exception; use WP_Error; @@ -80,13 +79,13 @@ protected function handle_item( Item $as3cf_item, Manifest $manifest, array $opt // we'll return an error. $current_provider = $this->as3cf->get_storage_provider(); if ( ! empty( $current_provider ) && $current_provider::get_provider_key_name() !== $as3cf_item->provider() ) { - $message = sprintf( + $error_msg = sprintf( __( '%1$s with ID %d is offloaded to a different provider than currently configured', 'amazon-s3-and-cloudfront' ), $this->as3cf->get_source_type_name( $as3cf_item->source_type() ), $as3cf_item->source_id() ); - return new WP_Error( 'exception', $message ); + return $this->return_handler_error( $error_msg ); } else { $provider_client = $this->as3cf->get_provider_client( $as3cf_item->region() ); @@ -148,20 +147,21 @@ private function download_object( $provider_client, $object ) { // Make sure the local directory exists. $dir = dirname( $object['SaveAs'] ); if ( ! is_dir( $dir ) && ! wp_mkdir_p( $dir ) ) { - $error_message = sprintf( __( 'The local directory %s does not exist and could not be created.', 'amazon-s3-and-cloudfront' ), $dir ); - AS3CF_Error::log( sprintf( __( 'There was an error attempting to download the file %s from the bucket: %s', 'amazon-s3-and-cloudfront' ), $object['Key'], $error_message ) ); + $error_msg = sprintf( __( 'The local directory %s does not exist and could not be created.', 'amazon-s3-and-cloudfront' ), $dir ); + $error_msg = sprintf( __( 'There was an error attempting to download the file %1$s from the bucket: %2$s', 'amazon-s3-and-cloudfront' ), $object['Key'], $error_msg ); + + return $this->return_handler_error( $error_msg ); } try { $provider_client->get_object( $object ); } catch ( Exception $e ) { - $error_msg = sprintf( __( 'Error downloading %1$s from bucket: %2$s', 'amazon-s3-and-cloudfront' ), $object['Key'], $e->getMessage() ); - AS3CF_Error::log( $error_msg ); - // If storage provider file doesn't exist, an empty local file will be created, clean it up. @unlink( $object['SaveAs'] ); - return new WP_Error( 'download_object', $error_msg ); + $error_msg = sprintf( __( 'Error downloading %1$s from bucket: %2$s', 'amazon-s3-and-cloudfront' ), $object['Key'], $e->getMessage() ); + + return $this->return_handler_error( $error_msg ); } return true; diff --git a/classes/items/item-handler.php b/classes/items/item-handler.php index df48e8db..02f05097 100644 --- a/classes/items/item-handler.php +++ b/classes/items/item-handler.php @@ -121,6 +121,11 @@ public function handle( Item $as3cf_item, array $options = array() ) { // Cancelled, let caller know that request was not handled. if ( false !== $cancel ) { + // If something unexpected happened, let the caller know. + if ( is_wp_error( $cancel ) ) { + return $this->return_result( $cancel, $as3cf_item, $options ); + } + return $this->return_result( false, $as3cf_item, $options ); } @@ -177,18 +182,24 @@ abstract protected function handle_item( Item $as3cf_item, Manifest $manifest, a abstract protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options ); /** - * Helper to record errors and return meta data on handler error. + * Helper to record errors and return them or optional supplied value. * - * @param string $error_msg - * @param array|null $return + * @param string|WP_Error $error_msg An error message or already constructed WP_Error. + * @param mixed|null $return Optional return value instead of WP_Error. * - * @return array|WP_Error + * @return mixed|WP_Error */ protected function return_handler_error( $error_msg, $return = null ) { - AS3CF_Error::log( $error_msg ); + if ( is_wp_error( $error_msg ) ) { + foreach ( $error_msg->get_error_messages() as $msg ) { + AS3CF_Error::Log( $msg ); + } + } else { + AS3CF_Error::log( $error_msg ); + } if ( is_null( $return ) ) { - return new WP_Error( 'exception', $error_msg ); + return is_wp_error( $error_msg ) ? $error_msg : new WP_Error( 'exception', $error_msg ); } return $return; diff --git a/classes/items/item.php b/classes/items/item.php index 29103329..6f9d3aa2 100644 --- a/classes/items/item.php +++ b/classes/items/item.php @@ -800,7 +800,7 @@ public static function get_by_source_id( $source_id ) { $source_id = (int) $source_id; - if ( empty( $source_id ) ) { + if ( $source_id < 0 ) { return false; } @@ -1410,7 +1410,7 @@ public static function get_item_source_by_remote_url( $url ) { * * While source id isn't strictly unique, it is by source type, which is always used in queries based on called class. * - * @param int $upper_bound Returned source_ids should be lower than this, use null/0 for no upper bound. + * @param int $upper_bound Returned source_ids should be lower than this, use null for no upper bound. * @param int $limit Maximum number of source_ids to return. Required if not counting. * @param bool $count Just return a count of matching source_ids? Negates $limit, default false. * @param int $originator Optionally restrict to only records with given originator type from ORIGINATORS const. @@ -1421,17 +1421,16 @@ public static function get_item_source_by_remote_url( $url ) { public static function get_source_ids( $upper_bound, $limit, $count = false, $originator = null, $is_verified = null ) { global $wpdb; - $args = array( static::$source_type ); - if ( $count ) { $sql = 'SELECT COUNT(DISTINCT source_id)'; } else { $sql = 'SELECT DISTINCT source_id'; } - $sql .= ' FROM ' . static::items_table() . ' WHERE source_type = %s'; + $sql .= ' FROM ' . static::items_table() . ' WHERE source_type = %s'; + $args = array( static::$source_type ); - if ( ! empty( $upper_bound ) ) { + if ( is_numeric( $upper_bound ) ) { $sql .= ' AND source_id < %d'; $args[] = $upper_bound; } @@ -1967,4 +1966,24 @@ public function offloaded_files() { return $offloaded_files; } + + /** + * Is the supplied item_source considered to be empty? + * + * @param array $item_source + * + * @return bool + */ + public static function is_empty_item_source( $item_source ) { + if ( + empty( $item_source['source_type'] ) || + ! isset( $item_source['id'] ) || + ! is_numeric( $item_source['id'] ) || + $item_source['id'] < 0 + ) { + return true; + } + + return false; + } } \ No newline at end of file diff --git a/classes/items/remove-local-handler.php b/classes/items/remove-local-handler.php index 37dc838f..00566f3f 100644 --- a/classes/items/remove-local-handler.php +++ b/classes/items/remove-local-handler.php @@ -3,7 +3,6 @@ namespace DeliciousBrains\WP_Offload_Media\Items; use AS3CF_Error; -use WP_Error; class Remove_Local_Handler extends Item_Handler { /** @@ -51,7 +50,7 @@ public static function default_options() { * @param Item $as3cf_item * @param array $options * - * @return Manifest|WP_Error + * @return Manifest */ protected function pre_handle( Item $as3cf_item, array $options ) { $manifest = new Manifest(); @@ -143,7 +142,7 @@ protected function pre_handle( Item $as3cf_item, array $options ) { * @param Manifest $manifest * @param array $options * - * @return bool|WP_Error + * @return bool */ protected function handle_item( Item $as3cf_item, Manifest $manifest, array $options ) { foreach ( $manifest->objects as &$file_to_remove ) { @@ -175,7 +174,7 @@ protected function handle_item( Item $as3cf_item, Manifest $manifest, array $opt * @param Manifest $manifest * @param array $options * - * @return bool|WP_Error + * @return bool */ protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options ) { if ( empty( $manifest->objects ) ) { diff --git a/classes/items/remove-provider-handler.php b/classes/items/remove-provider-handler.php index ab85d952..ee1df7ec 100644 --- a/classes/items/remove-provider-handler.php +++ b/classes/items/remove-provider-handler.php @@ -2,7 +2,6 @@ namespace DeliciousBrains\WP_Offload_Media\Items; -use AS3CF_Error; use Exception; use WP_Error; @@ -37,15 +36,15 @@ protected function pre_handle( Item $as3cf_item, array $options ) { $paths = array(); if ( ! empty( $options['object_keys'] ) && ! is_array( $options['object_keys'] ) ) { - return new WP_Error( 'remove-error', __( 'Invalid object_keys option provided.', 'amazon-s3-and-cloudfront' ) ); + return $this->return_handler_error( __( 'Invalid object_keys option provided.', 'amazon-s3-and-cloudfront' ) ); } if ( ! empty( $options['offloaded_files'] ) && ! is_array( $options['offloaded_files'] ) ) { - return new WP_Error( 'remove-error', __( 'Invalid offloaded_files option provided.', 'amazon-s3-and-cloudfront' ) ); + return $this->return_handler_error( __( 'Invalid offloaded_files option provided.', 'amazon-s3-and-cloudfront' ) ); } if ( ! empty( $options['object_keys'] ) && ! empty( $options['offloaded_files'] ) ) { - return new WP_Error( 'remove-error', __( 'Providing both object_keys and offloaded_files options is not supported.', 'amazon-s3-and-cloudfront' ) ); + return $this->return_handler_error( __( 'Providing both object_keys and offloaded_files options is not supported.', 'amazon-s3-and-cloudfront' ) ); } if ( empty( $options['offloaded_files'] ) ) { @@ -118,9 +117,9 @@ protected function handle_item( Item $as3cf_item, Manifest $manifest, array $opt ) ); } } catch ( Exception $e ) { - AS3CF_Error::log( 'Error removing files from bucket: ' . $e->getMessage() ); + $error_msg = sprintf( __( 'Error removing files from bucket: %s', 'amazon-s3-and-cloudfront' ), $e->getMessage() ); - return new WP_Error( 'remove-error', $e->getMessage() ); + return $this->return_handler_error( $error_msg ); } return true; @@ -133,7 +132,7 @@ protected function handle_item( Item $as3cf_item, Manifest $manifest, array $opt * @param Manifest $manifest * @param array $options * - * @return bool|WP_Error + * @return bool */ protected function post_handle( Item $as3cf_item, Manifest $manifest, array $options ) { return true; diff --git a/classes/upgrades/clear-postmeta-cache.php b/classes/upgrades/clear-postmeta-cache.php new file mode 100644 index 00000000..dcac8c98 --- /dev/null +++ b/classes/upgrades/clear-postmeta-cache.php @@ -0,0 +1,113 @@ +batch_limit}"; + $wpdb->query( $wpdb->prepare( $sql, array( $this->session[ $item ] ) ) ); + + return true; + } + + /** + * Count items left to process for the current blog. + * + * @return int + */ + protected function count_items_to_process() { + global $wpdb; + + // Store the highest known meta_id at the time we begin processing. + if ( empty( $this->session[ $this->blog_prefix ] ) ) { + $sql = "SELECT meta_id FROM {$this->blog_prefix}postmeta WHERE meta_key = 'amazonS3_cache' ORDER BY meta_id DESC LIMIT 0, 1;"; + $last = $wpdb->get_var( $sql ); + + $this->session[ $this->blog_prefix ] = $last; + } + + return count( $this->get_items_to_process( $this->blog_prefix, 0 ) ); + } + + /** + * Get array of items that each represent one chunk to be cleared. + * + * @param string $prefix Table prefix for blog. + * @param int $limit + * @param bool|mixed $offset + * + * @return array + */ + protected function get_items_to_process( $prefix, $limit, $offset = false ) { + $count = $this->get_real_count( $prefix ); + if ( 0 === $count ) { + return array(); + } + + $chunks = ceil( $count / $this->batch_limit ); + + return array_fill( 0, $chunks, $prefix ); + } + + /** + * Return the real number of remaining amazonS3_cache items to clear out. + * + * @param string $prefix + * + * @return int + */ + private function get_real_count( $prefix ) { + global $wpdb; + + $sql = "SELECT count(meta_id) FROM {$prefix}postmeta WHERE meta_key = 'amazonS3_cache' AND meta_id <= %d"; + $count = $wpdb->get_var( $wpdb->prepare( $sql, $this->session[ $prefix ] ) ); + + return (int) $count; + } +} diff --git a/languages/amazon-s3-and-cloudfront-en.pot b/languages/amazon-s3-and-cloudfront-en.pot index c6f5ea20..7e4a6242 100644 --- a/languages/amazon-s3-and-cloudfront-en.pot +++ b/languages/amazon-s3-and-cloudfront-en.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: amazon-s3-and-cloudfront\n" "Report-Msgid-Bugs-To: nom@deliciousbrains.com\n" -"POT-Creation-Date: 2022-03-09 13:52+0000\n" +"POT-Creation-Date: 2022-03-21 15:00+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,17 +17,17 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: classes/amazon-s3-and-cloudfront.php:195 #: classes/amazon-s3-and-cloudfront.php:196 +#: classes/amazon-s3-and-cloudfront.php:197 msgid "Offload Media Lite" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:436 -#: classes/amazon-s3-and-cloudfront.php:453 +#: classes/amazon-s3-and-cloudfront.php:438 +#: classes/amazon-s3-and-cloudfront.php:455 msgid "Unknown" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:534 +#: classes/amazon-s3-and-cloudfront.php:536 #: view/bucket-select.php:87 #: view/delivery-provider-select.php:129 #: view/delivery-provider-select.php:149 @@ -38,185 +38,185 @@ msgstr "" msgid "defined in wp-config.php" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1521 +#: classes/amazon-s3-and-cloudfront.php:1523 msgid "This action can only be performed through an admin screen." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1523 +#: classes/amazon-s3-and-cloudfront.php:1525 msgid "Cheatin’ eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1525 +#: classes/amazon-s3-and-cloudfront.php:1527 msgid "You do not have sufficient permissions to access this page." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1849 +#: classes/amazon-s3-and-cloudfront.php:1851 msgid "Error Getting Bucket Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1850 +#: classes/amazon-s3-and-cloudfront.php:1852 #, php-format msgid "There was an error attempting to get the region of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1953 +#: classes/amazon-s3-and-cloudfront.php:1955 msgid "" "This is a test file to check if the user has write permission to the bucket. " "Delete me if found." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1959 +#: classes/amazon-s3-and-cloudfront.php:1961 #, php-format msgid "" "There was an error attempting to check the permissions of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2077 +#: classes/amazon-s3-and-cloudfront.php:2079 msgid "Error creating bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2078 +#: classes/amazon-s3-and-cloudfront.php:2080 msgid "Bucket name too short." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2079 +#: classes/amazon-s3-and-cloudfront.php:2081 msgid "Bucket name too long." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2080 +#: classes/amazon-s3-and-cloudfront.php:2082 msgid "" "Invalid character. Bucket names can contain lowercase letters, numbers, " "periods and hyphens." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2081 +#: classes/amazon-s3-and-cloudfront.php:2083 msgid "Error saving bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2082 +#: classes/amazon-s3-and-cloudfront.php:2084 msgid "Error fetching buckets" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2083 +#: classes/amazon-s3-and-cloudfront.php:2085 msgid "Error getting URL preview: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2084 +#: classes/amazon-s3-and-cloudfront.php:2086 msgid "The changes you made will be lost if you navigate away from this page" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2085 +#: classes/amazon-s3-and-cloudfront.php:2087 msgid "Getting diagnostic info..." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2086 +#: classes/amazon-s3-and-cloudfront.php:2088 msgid "Error getting diagnostic info: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2087 +#: classes/amazon-s3-and-cloudfront.php:2089 msgctxt "placeholder for hidden access key, 39 char max" msgid "-- not shown --" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2089 -#: classes/amazon-s3-and-cloudfront.php:4210 +#: classes/amazon-s3-and-cloudfront.php:2091 +#: classes/amazon-s3-and-cloudfront.php:4212 msgid "Settings saved." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2211 +#: classes/amazon-s3-and-cloudfront.php:2213 msgid "Cheatin' eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2284 +#: classes/amazon-s3-and-cloudfront.php:2286 #, php-format msgid "Could not set new Delivery Provider: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2359 -#: classes/amazon-s3-and-cloudfront.php:2489 +#: classes/amazon-s3-and-cloudfront.php:2361 +#: classes/amazon-s3-and-cloudfront.php:2491 msgid "No bucket name provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2368 +#: classes/amazon-s3-and-cloudfront.php:2370 msgid "Bucket name not valid." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2381 +#: classes/amazon-s3-and-cloudfront.php:2383 msgid "No region provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2458 +#: classes/amazon-s3-and-cloudfront.php:2460 #, php-format msgctxt "Trying to change public access setting for given provider's bucket." msgid "Can't change Block All Public Access setting for %s buckets." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2467 +#: classes/amazon-s3-and-cloudfront.php:2469 msgid "No block public access setting provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2480 +#: classes/amazon-s3-and-cloudfront.php:2482 msgid "Storage Provider not configured with access credentials." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2507 +#: classes/amazon-s3-and-cloudfront.php:2509 msgid "Could not change Block All Public Access status for bucket." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2524 +#: classes/amazon-s3-and-cloudfront.php:2526 msgid "" "Failed to Enable Block All Public Access — We could " "not enable Block All Public Access. You will need to log in to the AWS " "Console and do it manually." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2526 +#: classes/amazon-s3-and-cloudfront.php:2528 msgid "" "Failed to Disable Block All Public Access — We could " "not disable Block All Public Access. You will need to log in to the AWS " "Console and do it manually." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2561 +#: classes/amazon-s3-and-cloudfront.php:2563 #: view/provider-select.php:329 msgctxt "placeholder for hidden secret access key, 39 char max" msgid "-- not shown --" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2584 +#: classes/amazon-s3-and-cloudfront.php:2586 msgid "Key File not valid JSON." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2604 -#: classes/amazon-s3-and-cloudfront.php:2618 -#: classes/amazon-s3-and-cloudfront.php:2627 +#: classes/amazon-s3-and-cloudfront.php:2606 +#: classes/amazon-s3-and-cloudfront.php:2620 +#: classes/amazon-s3-and-cloudfront.php:2629 msgctxt "missing form field" msgid " not provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2670 +#: classes/amazon-s3-and-cloudfront.php:2672 msgctxt "Show the media library tab" msgid "Media Library" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2671 +#: classes/amazon-s3-and-cloudfront.php:2673 msgctxt "Show the addons tab" msgid "Addons" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2672 +#: classes/amazon-s3-and-cloudfront.php:2674 msgctxt "Show the support tab" msgid "Support" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2849 +#: classes/amazon-s3-and-cloudfront.php:2851 #, php-format msgid "" "WP Offload Media — The file %s has been given %s " "permissions in the bucket." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2868 +#: classes/amazon-s3-and-cloudfront.php:2870 msgid "" "WP Offload Media Requirement Missing — Looks like you " "don't have an image manipulation library installed on this server and " @@ -224,7 +224,7 @@ msgid "" "Please setup GD or ImageMagick." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2892 +#: classes/amazon-s3-and-cloudfront.php:2894 #, php-format msgid "" "Missing Table — One or more required database tables " @@ -232,18 +232,18 @@ msgid "" "details. %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3714 +#: classes/amazon-s3-and-cloudfront.php:3716 #, php-format msgid "" "Define your access keys to enable write access to the " "bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3721 +#: classes/amazon-s3-and-cloudfront.php:3723 msgid "Quick Start Guide" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3723 +#: classes/amazon-s3-and-cloudfront.php:3725 #, php-format msgid "" "Looks like we don't have write access to this bucket. It's likely that the " @@ -252,7 +252,7 @@ msgid "" "correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3725 +#: classes/amazon-s3-and-cloudfront.php:3727 #, php-format msgid "" "Looks like we don't have access to the buckets. It's likely that the user " @@ -260,39 +260,39 @@ msgid "" "Please see our %s for instructions on setting up permissions correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3895 +#: classes/amazon-s3-and-cloudfront.php:3897 msgid "WP Offload Media Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3896 +#: classes/amazon-s3-and-cloudfront.php:3898 msgid "" "WP Offload Media Lite and WP Offload Media cannot both be active. We've " "automatically deactivated WP Offload Media Lite." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3898 +#: classes/amazon-s3-and-cloudfront.php:3900 msgid "WP Offload Media Lite Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3899 +#: classes/amazon-s3-and-cloudfront.php:3901 msgid "" "WP Offload Media Lite and WP Offload Media cannot both be active. We've " "automatically deactivated WP Offload Media." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3953 +#: classes/amazon-s3-and-cloudfront.php:3955 msgid "More info »" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4022 +#: classes/amazon-s3-and-cloudfront.php:4024 msgid "this doc" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4024 +#: classes/amazon-s3-and-cloudfront.php:4026 msgid "WP Offload Media Feature Removed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4025 +#: classes/amazon-s3-and-cloudfront.php:4027 #, php-format msgid "" "You had the \"Always non-SSL\" option selected in your settings, but we've " @@ -303,21 +303,21 @@ msgid "" "to the old behavior." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4173 +#: classes/amazon-s3-and-cloudfront.php:4175 msgid "Assets Pull" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4174 +#: classes/amazon-s3-and-cloudfront.php:4176 msgid "" "An addon for WP Offload Media to serve your site's JS, CSS, and other " "enqueued assets from Amazon CloudFront or another CDN." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4178 +#: classes/amazon-s3-and-cloudfront.php:4180 msgid "Feature" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4224 +#: classes/amazon-s3-and-cloudfront.php:4226 #, php-format msgid "" "Amazon Web Services Plugin No Longer Required — As of " @@ -328,7 +328,7 @@ msgid "" "plugin, it should be safe to deactivate and delete it. %2$s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4256 +#: classes/amazon-s3-and-cloudfront.php:4258 #, php-format msgid "" "WP Offload Media Settings Moved — You now define your " @@ -473,72 +473,71 @@ msgstr "" msgid "Can't create item from media library item %d" msgstr "" -#: classes/integrations/media-library.php:497 +#: classes/integrations/media-library.php:491 msgid "Offload" msgstr "" -#: classes/integrations/media-library.php:923 +#: classes/integrations/media-library.php:917 msgid "No" msgstr "" -#: classes/integrations/media-library.php:933 +#: classes/integrations/media-library.php:927 msgctxt "Storage provider key name" msgid "Storage Provider" msgstr "" -#: classes/integrations/media-library.php:934 +#: classes/integrations/media-library.php:928 msgctxt "Storage provider name" msgid "Storage Provider" msgstr "" -#: classes/integrations/media-library.php:935 +#: classes/integrations/media-library.php:929 msgctxt "Bucket name" msgid "Bucket" msgstr "" -#: classes/integrations/media-library.php:936 +#: classes/integrations/media-library.php:930 msgctxt "Path to file in bucket" msgid "Path" msgstr "" -#: classes/integrations/media-library.php:937 +#: classes/integrations/media-library.php:931 msgctxt "Location of bucket" msgid "Region" msgstr "" -#: classes/integrations/media-library.php:938 +#: classes/integrations/media-library.php:932 msgctxt "Access control list of the file in bucket" msgid "Access" msgstr "" -#: classes/integrations/media-library.php:939 +#: classes/integrations/media-library.php:933 msgid "URL" msgstr "" -#: classes/integrations/media-library.php:940 +#: classes/integrations/media-library.php:934 msgctxt "Whether or not metadata has been verified" msgid "Verified" msgstr "" -#: classes/items/download-handler.php:84 +#: classes/items/download-handler.php:83 msgid "" "%1$s with ID %d is offloaded to a different provider than currently " "configured" msgstr "" -#: classes/items/download-handler.php:151 +#: classes/items/download-handler.php:150 #, php-format msgid "The local directory %s does not exist and could not be created." msgstr "" -#: classes/items/download-handler.php:152 -#: classes/upgrades/upgrade-meta-wp-error.php:81 +#: classes/items/download-handler.php:151 #, php-format msgid "" -"There was an error attempting to download the file %s from the bucket: %s" +"There was an error attempting to download the file %1$s from the bucket: %2$s" msgstr "" -#: classes/items/download-handler.php:158 +#: classes/items/download-handler.php:162 #, php-format msgid "Error downloading %1$s from bucket: %2$s" msgstr "" @@ -565,19 +564,24 @@ msgstr "" msgid "Edit" msgstr "" -#: classes/items/remove-provider-handler.php:40 +#: classes/items/remove-provider-handler.php:39 msgid "Invalid object_keys option provided." msgstr "" -#: classes/items/remove-provider-handler.php:44 +#: classes/items/remove-provider-handler.php:43 msgid "Invalid offloaded_files option provided." msgstr "" -#: classes/items/remove-provider-handler.php:48 +#: classes/items/remove-provider-handler.php:47 msgid "" "Providing both object_keys and offloaded_files options is not supported." msgstr "" +#: classes/items/remove-provider-handler.php:120 +#, php-format +msgid "Error removing files from bucket: %s" +msgstr "" + #: classes/items/upload-handler.php:49 #, php-format msgid "%s with id %d does not have a valid file path" @@ -688,6 +692,10 @@ msgstr "" msgid "You must first set your access keys." msgstr "" +#: classes/upgrades/clear-postmeta-cache.php:40 +msgid "and clear old post meta cache items." +msgstr "" + #: classes/upgrades/upgrade-content-replace-urls.php:36 msgid "and ensuring that only the local URL exists in post content." msgstr "" @@ -755,6 +763,12 @@ msgid "" "and rebuilding the metadata for attachments that may have been corrupted." msgstr "" +#: classes/upgrades/upgrade-meta-wp-error.php:81 +#, php-format +msgid "" +"There was an error attempting to download the file %s from the bucket: %s" +msgstr "" + #: classes/upgrades/upgrade-region-meta.php:47 msgid "" "and updating the metadata with the bucket region it is served from. This " diff --git a/readme.txt b/readme.txt index 4c3631f4..f0cada0c 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, google Requires at least: 4.9 Tested up to: 5.9 Requires PHP: 5.6 -Stable tag: 2.6.0 +Stable tag: 2.6.1 License: GPLv3 Copies files to Amazon S3, DigitalOcean Spaces or Google Cloud Storage as they are uploaded to the Media Library. Optionally configure Amazon CloudFront or another CDN for faster delivery. @@ -85,6 +85,9 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin == Changelog == += WP Offload Media Lite 2.6.1 - 2022-03-21 = +* Bug fix: Local files are no longer removed if as3cf_pre_upload_attachment filter is used to abort upload + = WP Offload Media Lite 2.6 - 2022-03-09 = * [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-6-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting) * New: WP Offload Media is now compatible with WordPress 5.9 and Full Site Editing diff --git a/wordpress-s3.php b/wordpress-s3.php index a882ccb0..4be293f7 100644 --- a/wordpress-s3.php +++ b/wordpress-s3.php @@ -4,7 +4,7 @@ Plugin URI: http://wordpress.org/extend/plugins/amazon-s3-and-cloudfront/ Description: Automatically copies media uploads to Amazon S3, DigitalOcean Spaces or Google Cloud Storage for storage and delivery. Optionally configure Amazon CloudFront or another CDN for even faster delivery. Author: Delicious Brains -Version: 2.6.0 +Version: 2.6.1 Author URI: https://deliciousbrains.com/?utm_campaign=WP%2BOffload%2BS3&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting Network: True Text Domain: amazon-s3-and-cloudfront @@ -26,7 +26,7 @@ // Then completely rewritten. */ -$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '2.6.0'; +$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '2.6.1'; require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';