From 20d19b0945d7a665887d6cbe27531050d9323f2c Mon Sep 17 00:00:00 2001 From: "Ian M. Jones" Date: Mon, 25 Jun 2018 12:12:38 +0100 Subject: [PATCH] Deploying version 1.4.1 --- README.md | 5 +- classes/amazon-s3-and-cloudfront.php | 16 +-- classes/as3cf-plugin-base.php | 12 +++ classes/providers/provider.php | 4 +- languages/amazon-s3-and-cloudfront-en.pot | 116 +++++++++++----------- readme.txt | 5 +- wordpress-s3.php | 4 +- 7 files changed, 86 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 962f7dff..171c3e3e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Requires at least:** 4.6 **Tested up to:** 4.9 **Requires PHP:** 5.5 -**Stable tag:** 1.4 +**Stable tag:** 1.4.1 **License:** GPLv3 Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery. @@ -71,6 +71,9 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin ## Changelog ## +### WP Offload S3 Lite 1.4.1 - 2018-06-21 ### +* Bug fix: Incorrect filesize saved to metadata when image removed from local server + ### WP Offload S3 Lite 1.4 - 2018-06-12 ### * New: Using AWS PHP SDK v3 * New: Requires PHP 5.5+ diff --git a/classes/amazon-s3-and-cloudfront.php b/classes/amazon-s3-and-cloudfront.php index b42b37f3..981b0dc9 100644 --- a/classes/amazon-s3-and-cloudfront.php +++ b/classes/amazon-s3-and-cloudfront.php @@ -1015,6 +1015,8 @@ public function upload_attachment_to_s3( $post_id, $data = null, $file_path = nu return $this->return_upload_error( $error_msg, $return_metadata ); } + // Get original file's stats. + $filesize = filesize( $file_path ); $file_name = wp_basename( $file_path ); $type = get_post_mime_type( $post_id ); $allowed_types = $this->get_allowed_mime_types(); @@ -1163,7 +1165,7 @@ public function upload_attachment_to_s3( $post_id, $data = null, $file_path = nu $files_to_remove = array_unique( $files_to_remove ); // Delete the files and record original file's size before removal. - $filesize = $this->remove_local_files( $files_to_remove, $post_id ); + $this->remove_local_files( $files_to_remove, $post_id ); // Store filesize in the attachment meta data for use by WP if ( 0 < $filesize ) { @@ -1287,23 +1289,15 @@ protected function return_upload_error( $error_msg, $return = null ) { * * @param array $file_paths array of files to remove * @param int $attachment_id - * - * @return int Original file's size if attachment ID given, otherwise always 0. */ function remove_local_files( $file_paths, $attachment_id = 0 ) { - $filesize = 0; $filesize_total = 0; foreach ( $file_paths as $index => $path ) { if ( ! empty( $attachment_id ) && is_int( $attachment_id ) ) { $bytes = filesize( $path ); - if ( false !== $bytes ) { - $filesize_total += $bytes; - - // Will return the original file's size. - $filesize = $bytes; - } + $filesize_total += ( false !== $bytes ) ? $bytes : 0; } // Individual files might still be kept local, but we're still going to count them towards total above. @@ -1328,8 +1322,6 @@ function remove_local_files( $file_paths, $attachment_id = 0 ) { if ( $filesize_total > 0 ) { update_post_meta( $attachment_id, 'wpos3_filesize_total', $filesize_total ); } - - return $filesize; } /** diff --git a/classes/as3cf-plugin-base.php b/classes/as3cf-plugin-base.php index 818631d1..0bd4a815 100644 --- a/classes/as3cf-plugin-base.php +++ b/classes/as3cf-plugin-base.php @@ -312,6 +312,18 @@ function get_setting( $key, $default = '' ) { return apply_filters( 'as3cf_get_setting', $setting, $key ); } + /** + * Get a specific setting from the core plugin. + * + * @param $key + * @param string $default + * + * @return string + */ + public function get_core_setting( $key, $default = '' ) { + return $this->get_setting( $key, $default ); + } + /** * Gets a single setting that has been defined in the plugin settings constant * diff --git a/classes/providers/provider.php b/classes/providers/provider.php index c4d01042..73d1d755 100644 --- a/classes/providers/provider.php +++ b/classes/providers/provider.php @@ -110,7 +110,7 @@ public function get_access_key_id() { return $constant ? constant( $constant ) : ''; } - return $this->as3cf->get_setting( $this->access_key_id_setting_name ); + return $this->as3cf->get_core_setting( $this->access_key_id_setting_name ); } /** @@ -127,7 +127,7 @@ public function get_secret_access_key() { return $constant ? constant( $constant ) : ''; } - return $this->as3cf->get_setting( $this->secret_access_key_setting_name ); + return $this->as3cf->get_core_setting( $this->secret_access_key_setting_name ); } /** diff --git a/languages/amazon-s3-and-cloudfront-en.pot b/languages/amazon-s3-and-cloudfront-en.pot index 3134c9c9..32682d72 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: 2018-06-12 12:39+0100\n" +"POT-Creation-Date: 2018-06-25 11:52+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -44,7 +44,7 @@ msgid "The Access Key ID must be set." msgstr "" #: classes/amazon-s3-and-cloudfront.php:800 -#: classes/amazon-s3-and-cloudfront.php:2867 +#: classes/amazon-s3-and-cloudfront.php:2859 #: view/settings/settings.php:88 msgctxt "placeholder for hidden access key, 39 char max" msgid "-- not shown --" @@ -59,138 +59,138 @@ msgid "Access keys removed from the database successfully." msgstr "" #: classes/amazon-s3-and-cloudfront.php:1013 -#: classes/amazon-s3-and-cloudfront.php:1143 +#: classes/amazon-s3-and-cloudfront.php:1145 #, php-format msgid "File %s does not exist" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1024 +#: classes/amazon-s3-and-cloudfront.php:1026 #, php-format msgid "Mime type %s is not allowed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:1107 -#: classes/amazon-s3-and-cloudfront.php:1151 +#: classes/amazon-s3-and-cloudfront.php:1109 +#: classes/amazon-s3-and-cloudfront.php:1153 #, php-format msgid "Error uploading %s to S3: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2342 +#: classes/amazon-s3-and-cloudfront.php:2334 msgid "This action can only be performed through an admin screen." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2344 +#: classes/amazon-s3-and-cloudfront.php:2336 msgid "Cheatin’ eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2346 +#: classes/amazon-s3-and-cloudfront.php:2338 msgid "You do not have sufficient permissions to access this page." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2364 +#: classes/amazon-s3-and-cloudfront.php:2356 msgid "No bucket name provided." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2675 +#: classes/amazon-s3-and-cloudfront.php:2667 msgid "Error Getting Bucket Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2676 +#: classes/amazon-s3-and-cloudfront.php:2668 #, php-format msgid "There was an error attempting to get the region of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2789 +#: classes/amazon-s3-and-cloudfront.php:2781 msgid "" "This is a test file to check if the user has write permission to S3. Delete " "me if found." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2795 +#: classes/amazon-s3-and-cloudfront.php:2787 #, php-format msgid "" "There was an error attempting to check the permissions of the bucket %s: %s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2857 +#: classes/amazon-s3-and-cloudfront.php:2849 msgid "Error creating bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2858 +#: classes/amazon-s3-and-cloudfront.php:2850 msgid "Bucket name too short." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2859 +#: classes/amazon-s3-and-cloudfront.php:2851 msgid "Bucket name too long." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2860 +#: classes/amazon-s3-and-cloudfront.php:2852 msgid "" "Invalid character. Bucket names can contain lowercase letters, numbers, " "periods and hyphens." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2861 +#: classes/amazon-s3-and-cloudfront.php:2853 msgid "Error saving bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2862 +#: classes/amazon-s3-and-cloudfront.php:2854 msgid "Error fetching buckets" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2863 +#: classes/amazon-s3-and-cloudfront.php:2855 msgid "Error getting URL preview: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2864 +#: classes/amazon-s3-and-cloudfront.php:2856 msgid "The changes you made will be lost if you navigate away from this page" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2865 +#: classes/amazon-s3-and-cloudfront.php:2857 msgid "Getting diagnostic info..." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2866 +#: classes/amazon-s3-and-cloudfront.php:2858 msgid "Error getting diagnostic info: " msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2869 -#: classes/amazon-s3-and-cloudfront.php:4589 +#: classes/amazon-s3-and-cloudfront.php:2861 +#: classes/amazon-s3-and-cloudfront.php:4581 msgid "Settings saved." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2940 +#: classes/amazon-s3-and-cloudfront.php:2932 msgid "Cheatin' eh?" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2989 +#: classes/amazon-s3-and-cloudfront.php:2981 msgctxt "Show the media library tab" msgid "Media Library" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2990 +#: classes/amazon-s3-and-cloudfront.php:2982 msgctxt "Show the addons tab" msgid "Addons" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2991 +#: classes/amazon-s3-and-cloudfront.php:2983 msgctxt "Show the settings tab" msgid "Settings" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:2992 +#: classes/amazon-s3-and-cloudfront.php:2984 msgctxt "Show the support tab" msgid "Support" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3236 +#: classes/amazon-s3-and-cloudfront.php:3228 #, php-format msgid "" "WP Offload S3 — The file %s has been given %s " "permissions on Amazon S3." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3255 +#: classes/amazon-s3-and-cloudfront.php:3247 msgid "" "WP Offload S3 Requirement Missing — Looks like you " "don't have an image manipulation library installed on this server and " @@ -198,17 +198,17 @@ msgid "" "Please setup GD or ImageMagick." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3869 +#: classes/amazon-s3-and-cloudfront.php:3861 #, php-format msgid "" "Define your AWS keys to enable write access to the bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3876 +#: classes/amazon-s3-and-cloudfront.php:3868 msgid "Quick Start Guide" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3878 +#: classes/amazon-s3-and-cloudfront.php:3870 #, php-format msgid "" "Looks like we don't have write access to this bucket. It's likely that the " @@ -217,7 +217,7 @@ msgid "" "correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:3880 +#: classes/amazon-s3-and-cloudfront.php:3872 #, php-format msgid "" "Looks like we don't have access to the buckets. It's likely that the user " @@ -225,39 +225,39 @@ msgid "" "Please see our %s for instructions on setting up permissions correctly." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4030 +#: classes/amazon-s3-and-cloudfront.php:4022 msgid "WP Offload S3 Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4031 +#: classes/amazon-s3-and-cloudfront.php:4023 msgid "" "WP Offload S3 Lite and WP Offload S3 cannot both be active. We've " "automatically deactivated WP Offload S3 Lite." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4033 +#: classes/amazon-s3-and-cloudfront.php:4025 msgid "WP Offload S3 Lite Activation" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4034 +#: classes/amazon-s3-and-cloudfront.php:4026 msgid "" "WP Offload S3 Lite and WP Offload S3 cannot both be active. We've " "automatically deactivated WP Offload S3." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4086 +#: classes/amazon-s3-and-cloudfront.php:4078 msgid "More info »" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4181 +#: classes/amazon-s3-and-cloudfront.php:4173 msgid "this doc" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4183 +#: classes/amazon-s3-and-cloudfront.php:4175 msgid "WP Offload S3 Feature Removed" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4184 +#: classes/amazon-s3-and-cloudfront.php:4176 #, php-format msgid "" "You had the \"Always non-SSL\" option selected in your settings, but we've " @@ -268,50 +268,50 @@ msgid "" "to the old behavior." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4214 -#: classes/amazon-s3-and-cloudfront.php:4323 +#: classes/amazon-s3-and-cloudfront.php:4206 +#: classes/amazon-s3-and-cloudfront.php:4315 msgid "Amazon S3" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4324 +#: classes/amazon-s3-and-cloudfront.php:4316 msgctxt "Amazon S3 bucket" msgid "Bucket" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4325 +#: classes/amazon-s3-and-cloudfront.php:4317 msgctxt "Path to file on Amazon S3" msgid "Path" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4326 +#: classes/amazon-s3-and-cloudfront.php:4318 msgctxt "Location of Amazon S3 bucket" msgid "Region" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4327 +#: classes/amazon-s3-and-cloudfront.php:4319 msgctxt "Access control list of the file on Amazon S3" msgid "Access" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4328 +#: classes/amazon-s3-and-cloudfront.php:4320 msgid "URL" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4552 +#: classes/amazon-s3-and-cloudfront.php:4544 msgid "Assets Pull" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4553 +#: classes/amazon-s3-and-cloudfront.php:4545 msgid "" "An addon for WP Offload S3 to serve your site's JS, CSS, and other enqueued " "assets from Amazon CloudFront or another CDN." msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4557 +#: classes/amazon-s3-and-cloudfront.php:4549 msgid "Feature" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4603 +#: classes/amazon-s3-and-cloudfront.php:4595 #, php-format msgid "" "Amazon Web Services Plugin No Longer Required — As of " @@ -322,7 +322,7 @@ msgid "" "should be safe to deactivate and delete it. %2$s" msgstr "" -#: classes/amazon-s3-and-cloudfront.php:4635 +#: classes/amazon-s3-and-cloudfront.php:4627 #, php-format msgid "" "WP Offload S3 Settings Moved — You now define your " @@ -441,7 +441,7 @@ msgstr "" msgid "Invalid notice ID." msgstr "" -#: classes/as3cf-plugin-base.php:470 +#: classes/as3cf-plugin-base.php:482 msgid "Settings" msgstr "" diff --git a/readme.txt b/readme.txt index dbbb9d9f..8969fdf7 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: uploads, amazon, s3, amazon s3, mirror, admin, media, cdn, cloudfront Requires at least: 4.6 Tested up to: 4.9 Requires PHP: 5.5 -Stable tag: 1.4 +Stable tag: 1.4.1 License: GPLv3 Copies files to Amazon S3 as they are uploaded to the Media Library. Optionally configure Amazon CloudFront for faster delivery. @@ -67,6 +67,9 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin == Changelog == += WP Offload S3 Lite 1.4.1 - 2018-06-21 = +* Bug fix: Incorrect filesize saved to metadata when image removed from local server + = WP Offload S3 Lite 1.4 - 2018-06-12 = * New: Using AWS PHP SDK v3 * New: Requires PHP 5.5+ diff --git a/wordpress-s3.php b/wordpress-s3.php index 149b5106..8d71dbf3 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 for storage and delivery. Optionally configure Amazon CloudFront for even faster delivery. Author: Delicious Brains -Version: 1.4 +Version: 1.4.1 Author URI: https://deliciousbrains.com/ Network: True Text Domain: amazon-s3-and-cloudfront @@ -26,7 +26,7 @@ // Then completely rewritten. */ -$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '1.4'; +$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '1.4.1'; require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';