Skip to content

Commit

Permalink
Deploying version 2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmjones committed Nov 19, 2019
1 parent 93cd39b commit ac0998d
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 72 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Requires at least:** 4.9
**Tested up to:** 5.3
**Requires PHP:** 5.5
**Stable tag:** 2.3
**Stable tag:** 2.3.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.
Expand Down Expand Up @@ -89,6 +89,10 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin

## Changelog ##

### WP Offload Media Lite 2.3.1 - 2019-11-19 ###
* Bug fix: Uncaught Error: Cannot use object of type Media_Library_Item as array in wp-includes/media.php:217
* Bug fix: Image not automatically offloaded if subsizes not expected

### WP Offload Media Lite 2.3 - 2019-11-12 ###
* [Release Summary Blog Post](https://deliciousbrains.com/wp-offload-media-2-3-released/?utm_campaign=changelogs&utm_source=wordpress.org&utm_medium=free%2Bplugin%2Blisting)
* New: Upgrade routine to migrate offload data to custom table
Expand Down
20 changes: 16 additions & 4 deletions classes/amazon-s3-and-cloudfront.php
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,21 @@ function wp_update_attachment_metadata( $data, $post_id ) {
return $data;
}

// Protect against updates of partially formed metadata.
if ( wp_attachment_is_image( $post_id ) && empty( $data['sizes'] ) ) {
return $data;
// Protect against updates of partially formed metadata since WordPress 5.3.
// Checks whether new upload currently has no subsizes recorded but is expected to have subsizes during upload,
// and if so, are any of its currently missing sizes part of the set.
if ( function_exists( 'wp_get_registered_image_subsizes' ) && function_exists( 'wp_get_missing_image_subsizes' ) ) {
if ( empty( $data['sizes'] ) && wp_attachment_is_image( $post_id ) ) {

// There is no unified way of checking whether subsizes are expected, so we have to duplicate WordPress code here.
$new_sizes = wp_get_registered_image_subsizes();
$new_sizes = apply_filters( 'intermediate_image_sizes_advanced', $new_sizes, $data, $post_id );
$missing_sizes = wp_get_missing_image_subsizes( $post_id );

if ( ! empty( $new_sizes ) && ! empty( $missing_sizes ) && array_intersect_key( $missing_sizes, $new_sizes ) ) {
return $data;
}
}
}

$as3cf_item = Media_Library_Item::get_by_source_id( $post_id );
Expand All @@ -1086,7 +1098,7 @@ function wp_update_attachment_metadata( $data, $post_id ) {
// upload attachment to provider
$attachment_metadata = $this->upload_attachment( $post_id, $data );

if ( is_wp_error( $attachment_metadata ) ) {
if ( is_wp_error( $attachment_metadata ) || empty( $attachment_metadata ) || ! is_array( $attachment_metadata ) ) {
return $data;
}

Expand Down
Loading

0 comments on commit ac0998d

Please sign in to comment.