From 97a3dfc0e875723386a3db46a03f41672b6846a5 Mon Sep 17 00:00:00 2001 From: MichaelKo Date: Thu, 25 Nov 2021 15:26:26 +0100 Subject: [PATCH 1/2] add WP_STATELESS_SKIP_ACL_SET for skip ACL set for GCS --- lib/classes/class-gs-client.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/classes/class-gs-client.php b/lib/classes/class-gs-client.php index 4977ea0b9..a1312a1aa 100644 --- a/lib/classes/class-gs-client.php +++ b/lib/classes/class-gs-client.php @@ -250,15 +250,22 @@ public function add_media($args = array()) { // Reset to the client to execute requests immediately in the future. $this->client->setDefer(false); } else { - $media = $this->service->objects->insert($this->bucket, $media, array_filter(array( + $mediaOptions = array( 'data' => file_get_contents($args['absolutePath']), 'uploadType' => 'media', 'mimeType' => $args['mimeType'], - 'predefinedAcl' => 'bucketOwnerFullControl', - ))); + ); + + if (defined('WP_STATELESS_SKIP_ACL_SET') && !WP_STATELESS_SKIP_ACL_SET) { + $mediaOptions['predefinedAcl'] = 'bucketOwnerFullControl'; + } + + $media = $this->service->objects->insert($this->bucket, $media, array_filter($mediaOptions)); } - $this->mediaInsertACL($name, $media, $args); + if (defined('WP_STATELESS_SKIP_ACL_SET') && !WP_STATELESS_SKIP_ACL_SET) { + $this->mediaInsertACL($name, $media, $args); + } } catch (Exception $e) { return new WP_Error('sm_error', $e->getMessage()); } From 4cbb1c75267abfcbfcff19e943040e2b3dc5413e Mon Sep 17 00:00:00 2001 From: Alexey Bolgunovsky Date: Wed, 4 Oct 2023 19:00:44 +0300 Subject: [PATCH 2/2] Update class-gs-client.php Fix logic of processing new WP_STATELESS_SKIP_ACL_SET constant --- lib/classes/class-gs-client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/classes/class-gs-client.php b/lib/classes/class-gs-client.php index a1312a1aa..2bcf7bc98 100644 --- a/lib/classes/class-gs-client.php +++ b/lib/classes/class-gs-client.php @@ -256,14 +256,14 @@ public function add_media($args = array()) { 'mimeType' => $args['mimeType'], ); - if (defined('WP_STATELESS_SKIP_ACL_SET') && !WP_STATELESS_SKIP_ACL_SET) { + if ( !defined('WP_STATELESS_SKIP_ACL_SET') || !WP_STATELESS_SKIP_ACL_SET) { $mediaOptions['predefinedAcl'] = 'bucketOwnerFullControl'; } $media = $this->service->objects->insert($this->bucket, $media, array_filter($mediaOptions)); } - if (defined('WP_STATELESS_SKIP_ACL_SET') && !WP_STATELESS_SKIP_ACL_SET) { + if ( !defined('WP_STATELESS_SKIP_ACL_SET') || !WP_STATELESS_SKIP_ACL_SET) { $this->mediaInsertACL($name, $media, $args); } } catch (Exception $e) {