diff --git a/README.md b/README.md index 153e1aab..ff09b13b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ **Requires at least:** 5.5 \ **Tested up to:** 6.2 \ **Requires PHP:** 7.2 \ -**Stable tag:** 3.2.2 \ +**Stable tag:** 3.2.3 \ **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. @@ -103,6 +103,10 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin ## Changelog +### WP Offload Media Lite 3.2.3 - 2023-06-13 + +* Bug fix: Broken legacy amazonS3_info metadata no longer causes upgrade routines to fail + ### WP Offload Media Lite 3.2.2 - 2023-05-16 * Security: Updated AWS SDK and Google Cloud SDK to address a vulnerability in `guzzlehttp/psr7` as reported in [CVE-2023-29197](https://nvd.nist.gov/vuln/detail/CVE-2023-29197) diff --git a/assets/css/settings.css b/assets/css/settings.css index 9403387f..05f9626f 100644 --- a/assets/css/settings.css +++ b/assets/css/settings.css @@ -1 +1 @@ -.panel-row.svelte-41r5oq.svelte-41r5oq{position:relative}.header.svelte-41r5oq .gradient.svelte-41r5oq{position:absolute;width:144px;left:0;top:0;bottom:0;transform:matrix(-1, 0, 0, 1, 0, 0);border-top-right-radius:5px}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}.nav-status-wrapper.svelte-1i784er{position:relative}.content.svelte-5j10or.svelte-5j10or{padding:1.875rem 2.25rem 1.5rem 2.25rem;display:flex;flex-direction:column}.heading.svelte-5j10or.svelte-5j10or{margin-top:1rem;font-weight:700;font-size:1.125rem;line-height:140%}.description.svelte-5j10or.svelte-5j10or{margin-top:1rem;color:rgba(56, 54, 55, 0.7)}.benefits.svelte-5j10or.svelte-5j10or{margin-top:1.7rem;color:rgba(56, 54, 55, 0.7)}.benefits.svelte-5j10or li.svelte-5j10or{display:flex;align-items:center}.benefits.svelte-5j10or img.svelte-5j10or{height:40px;margin-left:-5px;margin-right:10px}.call-to-action.svelte-5j10or.svelte-5j10or{margin-top:0.7rem}.call-to-action.svelte-5j10or .note.svelte-5j10or{text-align:center}.notice-icon-wrapper.svelte-jtkdoa{display:inline-block;min-width:1.1875rem}.notice-icon.svelte-jtkdoa{margin-left:2px;margin-top:-1.5px;vertical-align:middle}#as3cf-settings.wpome div.panel.settings .header img.svelte-sglpwv.svelte-sglpwv{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-sglpwv.svelte-sglpwv{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-sglpwv h3.svelte-sglpwv{margin-left:0;margin-bottom:0.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv.svelte-sglpwv{display:flex;align-items:center;font-size:0.75rem}.console-details.svelte-sglpwv .console.svelte-sglpwv{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv a[target="_blank"].console.svelte-sglpwv:after{margin-right:0}#as3cf-settings.wpome div.panel.settings .header img.svelte-cn9mf.svelte-cn9mf{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-cn9mf.svelte-cn9mf{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-cn9mf h3.svelte-cn9mf{margin-left:0;margin-bottom:0.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf.svelte-cn9mf{display:flex;align-items:center;font-size:0.75rem}.console-details.svelte-cn9mf .console.svelte-cn9mf{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf a[target="_blank"].console.svelte-cn9mf:after{margin-right:0}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf .region.svelte-cn9mf{flex:1 0 auto;color:var(--as3cf-color-gray-500);margin:0 0.5rem}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}div.check-again.svelte-1oue4lo.svelte-1oue4lo{display:flex;flex-direction:column;align-items:flex-end;white-space:nowrap;min-width:6rem;padding-left:0.5rem;color:var(--as3cf-color-gray-700)}#as3cf-settings .check-again.svelte-1oue4lo .last-update.svelte-1oue4lo{padding-right:2px;margin-top:2px} \ No newline at end of file +.nav-status-wrapper.svelte-1i784er{position:relative}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}.panel-row.svelte-41r5oq.svelte-41r5oq{position:relative}.header.svelte-41r5oq .gradient.svelte-41r5oq{position:absolute;width:144px;left:0;top:0;bottom:0;transform:matrix(-1, 0, 0, 1, 0, 0);border-top-right-radius:5px}.content.svelte-5j10or.svelte-5j10or{padding:1.875rem 2.25rem 1.5rem 2.25rem;display:flex;flex-direction:column}.heading.svelte-5j10or.svelte-5j10or{margin-top:1rem;font-weight:700;font-size:1.125rem;line-height:140%}.description.svelte-5j10or.svelte-5j10or{margin-top:1rem;color:rgba(56, 54, 55, 0.7)}.benefits.svelte-5j10or.svelte-5j10or{margin-top:1.7rem;color:rgba(56, 54, 55, 0.7)}.benefits.svelte-5j10or li.svelte-5j10or{display:flex;align-items:center}.benefits.svelte-5j10or img.svelte-5j10or{height:40px;margin-left:-5px;margin-right:10px}.call-to-action.svelte-5j10or.svelte-5j10or{margin-top:0.7rem}.call-to-action.svelte-5j10or .note.svelte-5j10or{text-align:center}.notice-icon-wrapper.svelte-jtkdoa{display:inline-block;min-width:1.1875rem}.notice-icon.svelte-jtkdoa{margin-left:2px;margin-top:-1.5px;vertical-align:middle}#as3cf-settings.wpome div.panel.settings .header img.svelte-cn9mf.svelte-cn9mf{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-cn9mf.svelte-cn9mf{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-cn9mf h3.svelte-cn9mf{margin-left:0;margin-bottom:0.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf.svelte-cn9mf{display:flex;align-items:center;font-size:0.75rem}.console-details.svelte-cn9mf .console.svelte-cn9mf{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf a[target="_blank"].console.svelte-cn9mf:after{margin-right:0}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf .region.svelte-cn9mf{flex:1 0 auto;color:var(--as3cf-color-gray-500);margin:0 0.5rem}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}#as3cf-settings.wpome div.panel.settings .header img.svelte-sglpwv.svelte-sglpwv{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-sglpwv.svelte-sglpwv{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-sglpwv h3.svelte-sglpwv{margin-left:0;margin-bottom:0.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv.svelte-sglpwv{display:flex;align-items:center;font-size:0.75rem}.console-details.svelte-sglpwv .console.svelte-sglpwv{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv a[target="_blank"].console.svelte-sglpwv:after{margin-right:0}div.check-again.svelte-1oue4lo.svelte-1oue4lo{display:flex;flex-direction:column;align-items:flex-end;white-space:nowrap;min-width:6rem;padding-left:0.5rem;color:var(--as3cf-color-gray-700)}#as3cf-settings .check-again.svelte-1oue4lo .last-update.svelte-1oue4lo{padding-right:2px;margin-top:2px} \ No newline at end of file diff --git a/assets/css/settings.min.css b/assets/css/settings.min.css index 4830931a..c07555c5 100644 --- a/assets/css/settings.min.css +++ b/assets/css/settings.min.css @@ -1 +1 @@ -.panel-row.svelte-41r5oq.svelte-41r5oq{position:relative}.header.svelte-41r5oq .gradient.svelte-41r5oq{position:absolute;width:144px;left:0;top:0;bottom:0;transform:matrix(-1,0,0,1,0,0);border-top-right-radius:5px}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}.nav-status-wrapper.svelte-1i784er{position:relative}.content.svelte-5j10or.svelte-5j10or{padding:1.875rem 2.25rem 1.5rem 2.25rem;display:flex;flex-direction:column}.heading.svelte-5j10or.svelte-5j10or{margin-top:1rem;font-weight:700;font-size:1.125rem;line-height:140%}.description.svelte-5j10or.svelte-5j10or{margin-top:1rem;color:rgba(56,54,55,.7)}.benefits.svelte-5j10or.svelte-5j10or{margin-top:1.7rem;color:rgba(56,54,55,.7)}.benefits.svelte-5j10or li.svelte-5j10or{display:flex;align-items:center}.benefits.svelte-5j10or img.svelte-5j10or{height:40px;margin-left:-5px;margin-right:10px}.call-to-action.svelte-5j10or.svelte-5j10or{margin-top:.7rem}.call-to-action.svelte-5j10or .note.svelte-5j10or{text-align:center}.notice-icon-wrapper.svelte-jtkdoa{display:inline-block;min-width:1.1875rem}.notice-icon.svelte-jtkdoa{margin-left:2px;margin-top:-1.5px;vertical-align:middle}#as3cf-settings.wpome div.panel.settings .header img.svelte-sglpwv.svelte-sglpwv{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-sglpwv.svelte-sglpwv{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-sglpwv h3.svelte-sglpwv{margin-left:0;margin-bottom:.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv.svelte-sglpwv{display:flex;align-items:center;font-size:.75rem}.console-details.svelte-sglpwv .console.svelte-sglpwv{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv a[target="_blank"].console.svelte-sglpwv:after{margin-right:0}#as3cf-settings.wpome div.panel.settings .header img.svelte-cn9mf.svelte-cn9mf{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-cn9mf.svelte-cn9mf{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-cn9mf h3.svelte-cn9mf{margin-left:0;margin-bottom:.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf.svelte-cn9mf{display:flex;align-items:center;font-size:.75rem}.console-details.svelte-cn9mf .console.svelte-cn9mf{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf a[target="_blank"].console.svelte-cn9mf:after{margin-right:0}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf .region.svelte-cn9mf{flex:1 0 auto;color:var(--as3cf-color-gray-500);margin:0 .5rem}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}div.check-again.svelte-1oue4lo.svelte-1oue4lo{display:flex;flex-direction:column;align-items:flex-end;white-space:nowrap;min-width:6rem;padding-left:.5rem;color:var(--as3cf-color-gray-700)}#as3cf-settings .check-again.svelte-1oue4lo .last-update.svelte-1oue4lo{padding-right:2px;margin-top:2px} \ No newline at end of file +.nav-status-wrapper.svelte-1i784er{position:relative}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}.panel-row.svelte-41r5oq.svelte-41r5oq{position:relative}.header.svelte-41r5oq .gradient.svelte-41r5oq{position:absolute;width:144px;left:0;top:0;bottom:0;transform:matrix(-1,0,0,1,0,0);border-top-right-radius:5px}.content.svelte-5j10or.svelte-5j10or{padding:1.875rem 2.25rem 1.5rem 2.25rem;display:flex;flex-direction:column}.heading.svelte-5j10or.svelte-5j10or{margin-top:1rem;font-weight:700;font-size:1.125rem;line-height:140%}.description.svelte-5j10or.svelte-5j10or{margin-top:1rem;color:rgba(56,54,55,.7)}.benefits.svelte-5j10or.svelte-5j10or{margin-top:1.7rem;color:rgba(56,54,55,.7)}.benefits.svelte-5j10or li.svelte-5j10or{display:flex;align-items:center}.benefits.svelte-5j10or img.svelte-5j10or{height:40px;margin-left:-5px;margin-right:10px}.call-to-action.svelte-5j10or.svelte-5j10or{margin-top:.7rem}.call-to-action.svelte-5j10or .note.svelte-5j10or{text-align:center}.notice-icon-wrapper.svelte-jtkdoa{display:inline-block;min-width:1.1875rem}.notice-icon.svelte-jtkdoa{margin-left:2px;margin-top:-1.5px;vertical-align:middle}#as3cf-settings.wpome div.panel.settings .header img.svelte-cn9mf.svelte-cn9mf{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-cn9mf.svelte-cn9mf{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-cn9mf h3.svelte-cn9mf{margin-left:0;margin-bottom:.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf.svelte-cn9mf{display:flex;align-items:center;font-size:.75rem}.console-details.svelte-cn9mf .console.svelte-cn9mf{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf a[target="_blank"].console.svelte-cn9mf:after{margin-right:0}#as3cf-settings.wpome div.panel .console-details.svelte-cn9mf .region.svelte-cn9mf{flex:1 0 auto;color:var(--as3cf-color-gray-500);margin:0 .5rem}.toggler.svelte-k1tgof:not(.toggleDisabled){cursor:pointer}#as3cf-settings.wpome div.panel.settings .header img.svelte-sglpwv.svelte-sglpwv{width:var(--as3cf-settings-ctrl-width);height:var(--as3cf-settings-ctrl-width)}.provider-details.svelte-sglpwv.svelte-sglpwv{display:flex;flex-direction:column;flex:auto;margin-left:var(--as3cf-settings-option-indent);z-index:1}#as3cf-settings.wpome div.panel .provider-details.svelte-sglpwv h3.svelte-sglpwv{margin-left:0;margin-bottom:.5rem}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv.svelte-sglpwv{display:flex;align-items:center;font-size:.75rem}.console-details.svelte-sglpwv .console.svelte-sglpwv{flex:0 1 min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#as3cf-settings.wpome div.panel .console-details.svelte-sglpwv a[target="_blank"].console.svelte-sglpwv:after{margin-right:0}div.check-again.svelte-1oue4lo.svelte-1oue4lo{display:flex;flex-direction:column;align-items:flex-end;white-space:nowrap;min-width:6rem;padding-left:.5rem;color:var(--as3cf-color-gray-700)}#as3cf-settings .check-again.svelte-1oue4lo .last-update.svelte-1oue4lo{padding-right:2px;margin-top:2px} \ No newline at end of file diff --git a/classes/as3cf-utils.php b/classes/as3cf-utils.php index 6052c24a..e6c641ad 100644 --- a/classes/as3cf-utils.php +++ b/classes/as3cf-utils.php @@ -813,7 +813,7 @@ public static function maybe_fix_serialized_string( $input ) { return $input; } - $output = preg_replace_callback( '/s:(\d+):"(.*?)";/', + $output = preg_replace_callback( '/s:(\d+):"(.*?)"\s?;/', array( __CLASS__, 'fix_serialized_matches' ), $output ); diff --git a/classes/items/item.php b/classes/items/item.php index 7c122f7c..34cf2160 100644 --- a/classes/items/item.php +++ b/classes/items/item.php @@ -494,7 +494,7 @@ private static function get_from_items_cache_by_bucket_and_path( $bucket, $path * * @return string */ - protected static function items_table() { + public static function items_table(): string { global $wpdb; /* @var Amazon_S3_And_CloudFront $as3cf */ diff --git a/classes/upgrades/upgrade-file-sizes.php b/classes/upgrades/upgrade-file-sizes.php index c865c3f8..fee35f8b 100644 --- a/classes/upgrades/upgrade-file-sizes.php +++ b/classes/upgrades/upgrade-file-sizes.php @@ -12,6 +12,7 @@ namespace DeliciousBrains\WP_Offload_Media\Upgrades; use AS3CF_Error; +use AS3CF_Utils; use DeliciousBrains\WP_Offload_Media\Items\Media_Library_Item; use Exception; @@ -58,7 +59,11 @@ protected function get_running_update_text() { * @throws Exception */ protected function upgrade_item( $item ) { - $provider_object = unserialize( $item->provider_object ); + $provider_object = AS3CF_Utils::maybe_fix_serialized_string( $item->provider_object ); + $fixed = $item->provider_object !== $provider_object; + + $provider_object = unserialize( $provider_object ); + if ( false === $provider_object ) { AS3CF_Error::log( 'Failed to unserialize offload meta for attachment ' . $item->ID . ': ' . $item->provider_object ); $this->error_count++; @@ -66,6 +71,18 @@ protected function upgrade_item( $item ) { return false; } + if ( $fixed ) { + if ( update_post_meta( $item->ID, 'amazonS3_info', $provider_object ) ) { + $msg = sprintf( __( 'Fixed legacy amazonS3_info metadata when updating file size metadata, please check bucket and path for attachment ID %1$s', 'amazon-s3-and-cloudfront' ), $item->ID ); + AS3CF_Error::log( $msg ); + } else { + AS3CF_Error::log( 'Failed to fix broken serialized legacy offload metadata for attachment ' . $item->ID . ': ' . $item->provider_object ); + $this->error_count++; + + return false; + } + } + // Using Media_Library_Item::get_by_source_id falls back to legacy metadata and substitutes in defaults and potentially missing values. $as3cf_item = Media_Library_Item::get_by_source_id( $item->ID ); @@ -190,4 +207,4 @@ protected function get_provider_attachments( $prefix, $limit = null ) { return $wpdb->get_results( $sql, OBJECT ); } -} \ No newline at end of file +} diff --git a/classes/upgrades/upgrade-items-table.php b/classes/upgrades/upgrade-items-table.php index e2c2ab46..84772ba6 100644 --- a/classes/upgrades/upgrade-items-table.php +++ b/classes/upgrades/upgrade-items-table.php @@ -12,6 +12,7 @@ namespace DeliciousBrains\WP_Offload_Media\Upgrades; use AS3CF_Error; +use AS3CF_Utils; use DeliciousBrains\WP_Offload_Media\Items\Media_Library_Item; /** @@ -55,8 +56,11 @@ protected function get_running_update_text() { * @return bool */ protected function upgrade_item( $item ) { + $provider_object = AS3CF_Utils::maybe_fix_serialized_string( $item->provider_object ); + $fixed = $item->provider_object !== $provider_object; + // Make sure legacy metadata isn't broken. - $provider_object = unserialize( $item->provider_object ); + $provider_object = unserialize( $provider_object ); if ( false === $provider_object ) { AS3CF_Error::log( 'Failed to unserialize legacy offload metadata for attachment ' . $item->ID . ': ' . $item->provider_object ); @@ -72,6 +76,18 @@ protected function upgrade_item( $item ) { return false; } + if ( $fixed ) { + if ( update_post_meta( $item->ID, 'amazonS3_info', $provider_object ) ) { + $msg = sprintf( __( 'Fixed legacy amazonS3_info metadata when moved to %1$s table, please check bucket and path for attachment ID %2$s', 'amazon-s3-and-cloudfront' ), Media_Library_Item::items_table(), $item->ID ); + AS3CF_Error::log( $msg ); + } else { + AS3CF_Error::log( 'Failed to fix broken serialized legacy offload metadata for attachment ' . $item->ID . ': ' . $item->provider_object ); + $this->error_count++; + + return false; + } + } + // Using Media_Library_Item::get_by_source_id falls back to legacy metadata and substitutes in defaults and potentially missing values. // If we're here we already know there's legacy metadata and that there isn't a new items table record yet, // or there's legacy metadata and an existing items table record that we can just re-save without issue before deleting legacy metadata. @@ -170,4 +186,4 @@ protected function get_attachments_with_legacy_metadata( $prefix, $count = false return $wpdb->get_results( $sql, OBJECT ); } -} \ No newline at end of file +} diff --git a/classes/upgrades/upgrade-meta-wp-error.php b/classes/upgrades/upgrade-meta-wp-error.php index 76296864..f633fa0c 100644 --- a/classes/upgrades/upgrade-meta-wp-error.php +++ b/classes/upgrades/upgrade-meta-wp-error.php @@ -12,6 +12,7 @@ namespace DeliciousBrains\WP_Offload_Media\Upgrades; use AS3CF_Error; +use AS3CF_Utils; use Exception; /** @@ -57,7 +58,11 @@ protected function get_running_update_text() { * @return bool */ protected function upgrade_item( $item ) { - $provider_object = unserialize( $item->provider_object ); + $provider_object = AS3CF_Utils::maybe_fix_serialized_string( $item->provider_object ); + $fixed = $item->provider_object !== $provider_object; + + $provider_object = unserialize( $provider_object ); + if ( false === $provider_object ) { AS3CF_Error::log( 'Failed to unserialize offload meta for attachment ' . $item->ID . ': ' . $item->provider_object ); $this->error_count++; @@ -65,6 +70,18 @@ protected function upgrade_item( $item ) { return false; } + if ( $fixed ) { + if ( update_post_meta( $item->ID, 'amazonS3_info', $provider_object ) ) { + $msg = sprintf( __( 'Fixed legacy amazonS3_info metadata when rebuilding corrupted attachment metadata, please check bucket and path for attachment ID %1$s', 'amazon-s3-and-cloudfront' ), $item->ID ); + AS3CF_Error::log( $msg ); + } else { + AS3CF_Error::log( 'Failed to fix broken serialized legacy offload metadata for attachment ' . $item->ID . ': ' . $item->provider_object ); + $this->error_count++; + + return false; + } + } + $file = get_attached_file( $item->ID, true ); if ( ! file_exists( $file ) ) { @@ -151,4 +168,4 @@ protected function get_attachments_with_error_metadata( $prefix, $count = false, return $wpdb->get_results( $sql, OBJECT ); } -} \ No newline at end of file +} diff --git a/classes/upgrades/upgrade-region-meta.php b/classes/upgrades/upgrade-region-meta.php index eab6522b..f4dde247 100644 --- a/classes/upgrades/upgrade-region-meta.php +++ b/classes/upgrades/upgrade-region-meta.php @@ -12,6 +12,7 @@ namespace DeliciousBrains\WP_Offload_Media\Upgrades; use AS3CF_Error; +use AS3CF_Utils; use DeliciousBrains\WP_Offload_Media\Items\Media_Library_Item; /** @@ -55,7 +56,11 @@ protected function get_running_update_text() { * @return bool */ protected function upgrade_item( $item ) { - $provider_object = unserialize( $item->provider_object ); + $provider_object = AS3CF_Utils::maybe_fix_serialized_string( $item->provider_object ); + $fixed = $item->provider_object !== $provider_object; + + $provider_object = unserialize( $provider_object ); + if ( false === $provider_object ) { AS3CF_Error::log( 'Failed to unserialize offload meta for attachment ' . $item->ID . ': ' . $item->provider_object ); $this->error_count++; @@ -63,6 +68,18 @@ protected function upgrade_item( $item ) { return false; } + if ( $fixed ) { + if ( update_post_meta( $item->ID, 'amazonS3_info', $provider_object ) ) { + $msg = sprintf( __( 'Fixed legacy amazonS3_info metadata when updating its region, please check bucket and path for attachment ID %1$s', 'amazon-s3-and-cloudfront' ), $item->ID ); + AS3CF_Error::log( $msg ); + } else { + AS3CF_Error::log( 'Failed to fix broken serialized legacy offload metadata for attachment ' . $item->ID . ': ' . $item->provider_object ); + $this->error_count++; + + return false; + } + } + // Using Media_Library_Item::get_by_source_id falls back to legacy metadata and substitutes in defaults and potentially missing values. $as3cf_item = Media_Library_Item::get_by_source_id( $item->ID ); diff --git a/languages/amazon-s3-and-cloudfront-en.pot b/languages/amazon-s3-and-cloudfront-en.pot index 7d5c76cc..5828951c 100644 --- a/languages/amazon-s3-and-cloudfront-en.pot +++ b/languages/amazon-s3-and-cloudfront-en.pot @@ -2,14 +2,14 @@ # # This file is distributed under the same license as the amazon-s3-and-cloudfront package. msgid "" msgstr "" -"Project-Id-Version: amazon-s3-and-cloudfront 3.2.2\n" +"Project-Id-Version: amazon-s3-and-cloudfront 3.2.3\n" "Report-Msgid-Bugs-To: mailto:nom@deliciousbrains.com\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-05-18T08:37:11+00:00\n" +"POT-Creation-Date: 2023-06-13T14:03:36+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.5.0\n" "X-Domain: amazon-s3-and-cloudfront\n" @@ -1805,10 +1805,14 @@ msgstr "" msgid "and ensuring that only the local URL exists in EDD post meta." msgstr "" -#: classes/upgrades/upgrade-file-sizes.php:49 +#: classes/upgrades/upgrade-file-sizes.php:50 msgid "and updating the metadata with the sizes of files that have been removed from the server. This will allow us to serve the correct size for media items and the total space used in Multisite subsites." msgstr "" +#: classes/upgrades/upgrade-file-sizes.php:76 +msgid "Fixed legacy amazonS3_info metadata when updating file size metadata, please check bucket and path for attachment ID %1$s" +msgstr "" + #: classes/upgrades/upgrade-filter-post-excerpt.php:36 msgid "and ensuring that only the local URL exists in post excerpts." msgstr "" @@ -1834,22 +1838,34 @@ msgstr "" msgid "and updating metadata about offloaded items to new format." msgstr "" -#: classes/upgrades/upgrade-items-table.php:47 +#: classes/upgrades/upgrade-items-table.php:48 msgid "and updating the plugin's metadata to use a faster storage method. During the update the site's total offloaded media count may be inaccurate but will settle down shortly after completing." msgstr "" -#: classes/upgrades/upgrade-meta-wp-error.php:49 +#: classes/upgrades/upgrade-items-table.php:81 +msgid "Fixed legacy amazonS3_info metadata when moved to %1$s table, please check bucket and path for attachment ID %2$s" +msgstr "" + +#: classes/upgrades/upgrade-meta-wp-error.php:50 msgid "and rebuilding the metadata for attachments that may have been corrupted." msgstr "" -#: classes/upgrades/upgrade-meta-wp-error.php:81 +#: classes/upgrades/upgrade-meta-wp-error.php:75 +msgid "Fixed legacy amazonS3_info metadata when rebuilding corrupted attachment metadata, please check bucket and path for attachment ID %1$s" +msgstr "" + +#: classes/upgrades/upgrade-meta-wp-error.php:98 msgid "There was an error attempting to download the file %s from the bucket: %s" msgstr "" -#: classes/upgrades/upgrade-region-meta.php:47 +#: classes/upgrades/upgrade-region-meta.php:48 msgid "and updating the metadata with the bucket region it is served from. This will allow us to serve your files from the proper region subdomain (e.g. s3-us-west-2.amazonaws.com)." msgstr "" +#: classes/upgrades/upgrade-region-meta.php:73 +msgid "Fixed legacy amazonS3_info metadata when updating its region, please check bucket and path for attachment ID %1$s" +msgstr "" + #: classes/upgrades/upgrade-tools-errors.php:38 msgid "and reformatting internal data about previous errors from tools." msgstr "" diff --git a/readme.txt b/readme.txt index 99fb8f8f..c9fa5583 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, google Requires at least: 5.5 Tested up to: 6.2 Requires PHP: 7.2 -Stable tag: 3.2.2 +Stable tag: 3.2.3 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 3.2.3 - 2023-06-13 = +* Bug fix: Broken legacy amazonS3_info metadata no longer causes upgrade routines to fail + = WP Offload Media Lite 3.2.2 - 2023-05-16 = * Security: Updated AWS SDK and Google Cloud SDK to address a vulnerability in `guzzlehttp/psr7` as reported in [CVE-2023-29197](https://nvd.nist.gov/vuln/detail/CVE-2023-29197) diff --git a/vendor/Gcp/ramsey/collection/README.md b/vendor/Gcp/ramsey/collection/README.md deleted file mode 100644 index c77ffcb1..00000000 --- a/vendor/Gcp/ramsey/collection/README.md +++ /dev/null @@ -1,70 +0,0 @@ -

ramsey/collection

- -

- A PHP library for representing and manipulating collections. -

- -

- Source Code - Download Package - PHP Programming Language - Read License - Build Status - Codecov Code Coverage - Psalm Type Coverage -

- -## About - -ramsey/collection is a PHP library for representing and manipulating collections. - -Much inspiration for this library came from the [Java Collections Framework][java]. - -This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). -By participating in this project and its community, you are expected to -uphold this code. - -## Installation - -Install this package as a dependency using [Composer](https://getcomposer.org). - -``` bash -composer require ramsey/collection -``` - -## Usage - -Examples of how to use this library may be found in the -[Wiki pages](https://github.com/ramsey/collection/wiki/Examples). - -## Contributing - -Contributions are welcome! To contribute, please familiarize yourself with -[CONTRIBUTING.md](CONTRIBUTING.md). - -## Coordinated Disclosure - -Keeping user information safe and secure is a top priority, and we welcome the -contribution of external security researchers. If you believe you've found a -security issue in software that is maintained in this repository, please read -[SECURITY.md][] for instructions on submitting a vulnerability report. - -## ramsey/collection for Enterprise - -Available as part of the Tidelift Subscription. - -The maintainers of ramsey/collection and thousands of other packages are working -with Tidelift to deliver commercial support and maintenance for the open source -packages you use to build your applications. Save time, reduce risk, and improve -code health, while paying the maintainers of the exact packages you use. -[Learn more.](https://tidelift.com/subscription/pkg/packagist-ramsey-collection?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - -## Copyright and License - -The ramsey/collection library is copyright © [Ben Ramsey](https://benramsey.com) -and licensed for use under the terms of the -MIT License (MIT). Please see [LICENSE](LICENSE) for more information. - - -[java]: http://docs.oracle.com/javase/8/docs/technotes/guides/collections/index.html -[security.md]: https://github.com/ramsey/collection/blob/main/SECURITY.md diff --git a/vendor/Gcp/ramsey/uuid/README.md b/vendor/Gcp/ramsey/uuid/README.md deleted file mode 100644 index 97e81a50..00000000 --- a/vendor/Gcp/ramsey/uuid/README.md +++ /dev/null @@ -1,83 +0,0 @@ -

ramsey/uuid

- -

- A PHP library for generating and working with UUIDs. -

- -

- Source Code - Download Package - PHP Programming Language - Read License - Build Status - Codecov Code Coverage - Psalm Type Coverage -

- -ramsey/uuid is a PHP library for generating and working with universally unique -identifiers (UUIDs). - -This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). -By participating in this project and its community, you are expected to -uphold this code. - -Much inspiration for this library came from the [Java][javauuid] and -[Python][pyuuid] UUID libraries. - -## Installation - -The preferred method of installation is via [Composer][]. Run the following -command to install the package and add it as a requirement to your project's -`composer.json`: - -```bash -composer require ramsey/uuid -``` - -## Upgrading to Version 4 - -See the documentation for a thorough upgrade guide: - -* [Upgrading ramsey/uuid Version 3 to 4](https://uuid.ramsey.dev/en/latest/upgrading/3-to-4.html) - -## Documentation - -Please see for documentation, tips, examples, and -frequently asked questions. - -## Contributing - -Contributions are welcome! To contribute, please familiarize yourself with -[CONTRIBUTING.md](CONTRIBUTING.md). - -## Coordinated Disclosure - -Keeping user information safe and secure is a top priority, and we welcome the -contribution of external security researchers. If you believe you've found a -security issue in software that is maintained in this repository, please read -[SECURITY.md][] for instructions on submitting a vulnerability report. - -## ramsey/uuid for Enterprise - -Available as part of the Tidelift Subscription. - -The maintainers of ramsey/uuid and thousands of other packages are working with -Tidelift to deliver commercial support and maintenance for the open source -packages you use to build your applications. Save time, reduce risk, and improve -code health, while paying the maintainers of the exact packages you use. -[Learn more.](https://tidelift.com/subscription/pkg/packagist-ramsey-uuid?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - -## Copyright and License - -The ramsey/uuid library is copyright © [Ben Ramsey](https://benramsey.com/) and -licensed for use under the MIT License (MIT). Please see [LICENSE][] for more -information. - -[rfc4122]: http://tools.ietf.org/html/rfc4122 -[conduct]: https://github.com/ramsey/uuid/blob/main/CODE_OF_CONDUCT.md -[javauuid]: http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html -[pyuuid]: http://docs.python.org/3/library/uuid.html -[composer]: http://getcomposer.org/ -[contributing.md]: https://github.com/ramsey/uuid/blob/main/CONTRIBUTING.md -[security.md]: https://github.com/ramsey/uuid/blob/main/SECURITY.md -[license]: https://github.com/ramsey/uuid/blob/main/LICENSE diff --git a/vendor/Gcp/symfony/polyfill-ctype/README.md b/vendor/Gcp/symfony/polyfill-ctype/README.md deleted file mode 100644 index b144d03c..00000000 --- a/vendor/Gcp/symfony/polyfill-ctype/README.md +++ /dev/null @@ -1,12 +0,0 @@ -Symfony Polyfill / Ctype -======================== - -This component provides `ctype_*` functions to users who run php versions without the ctype extension. - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/vendor/Gcp/symfony/polyfill-php80/README.md b/vendor/Gcp/symfony/polyfill-php80/README.md deleted file mode 100644 index 3816c559..00000000 --- a/vendor/Gcp/symfony/polyfill-php80/README.md +++ /dev/null @@ -1,25 +0,0 @@ -Symfony Polyfill / Php80 -======================== - -This component provides features added to PHP 8.0 core: - -- [`Stringable`](https://php.net/stringable) interface -- [`fdiv`](https://php.net/fdiv) -- [`ValueError`](https://php.net/valueerror) class -- [`UnhandledMatchError`](https://php.net/unhandledmatcherror) class -- `FILTER_VALIDATE_BOOL` constant -- [`get_debug_type`](https://php.net/get_debug_type) -- [`PhpToken`](https://php.net/phptoken) class -- [`preg_last_error_msg`](https://php.net/preg_last_error_msg) -- [`str_contains`](https://php.net/str_contains) -- [`str_starts_with`](https://php.net/str_starts_with) -- [`str_ends_with`](https://php.net/str_ends_with) -- [`get_resource_id`](https://php.net/get_resource_id) - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/vendor/Gcp/symfony/polyfill-php81/README.md b/vendor/Gcp/symfony/polyfill-php81/README.md deleted file mode 100644 index 7d8dd190..00000000 --- a/vendor/Gcp/symfony/polyfill-php81/README.md +++ /dev/null @@ -1,17 +0,0 @@ -Symfony Polyfill / Php81 -======================== - -This component provides features added to PHP 8.1 core: - -- [`array_is_list`](https://php.net/array_is_list) -- [`enum_exists`](https://php.net/enum-exists) -- [`MYSQLI_REFRESH_REPLICA`](https://php.net/mysqli.constants#constantmysqli-refresh-replica) constant -- [`ReturnTypeWillChange`](https://wiki.php.net/rfc/internal_method_return_types) - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/wordpress-s3.php b/wordpress-s3.php index 5c13cf50..be7c1792 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: 3.2.2 +Version: 3.2.3 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 @@ -28,7 +28,7 @@ // phpcs:disable SlevomatCodingStandard.Variables.UnusedVariable -$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '3.2.2'; +$GLOBALS['aws_meta']['amazon-s3-and-cloudfront']['version'] = '3.2.3'; require_once dirname( __FILE__ ) . '/classes/as3cf-compatibility-check.php';