This commit is contained in:
Javier Casares 2026-08-10 16:21:45 +00:00
commit cc1bca74fa

View file

@ -198,6 +198,9 @@ class Media_Uploader {
'Bucket' => $bucket,
'Key' => $object_key,
'Body' => $fh,
// ACL is public-read by design: this plugin serves media via a CDN
// or S3 URL. Files must be publicly accessible for WordPress to
// display them. Bucket policies should restrict list access separately.
'ACL' => 'public-read',
)
);
@ -377,17 +380,6 @@ class Media_Uploader {
return;
}
if ( ! function_exists( 'WP_Filesystem' ) ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
WP_Filesystem();
global $wp_filesystem;
if ( ! ( $wp_filesystem instanceof \WP_Filesystem_Base ) ) {
$this->logger->error( 'WP_Filesystem not available, aborting cleanup' );
return;
}
$current_time = time();
$new_queue = array();
$deleted = 0;
@ -414,8 +406,11 @@ class Media_Uploader {
continue;
}
if ( $wp_filesystem->exists( $file_path ) ) {
$deleted_ok = $wp_filesystem->delete( $file_path );
if ( file_exists( $file_path ) ) {
// Use unlink directly: wp_delete_file() returns void on WP < 6.7,
// so the boolean return is unreliable across the declared WP range.
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read -- cron cleanup, WP_Filesystem unavailable without credentials
$deleted_ok = unlink( $file_path );
if ( $deleted_ok ) {
++$deleted;
} else {