summaryrefslogtreecommitdiff
path: root/init.php
diff options
context:
space:
mode:
Diffstat (limited to 'init.php')
-rw-r--r--init.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/init.php b/init.php
index 10946c9..d8b42ab 100644
--- a/init.php
+++ b/init.php
@@ -34,17 +34,22 @@ class Cache_S3 extends Plugin implements Cache_Adapter {
Config::add(self::CACHE_S3_ACCESS_KEY, "", Config::T_STRING);
Config::add(self::CACHE_S3_SECRET_KEY, "", Config::T_STRING);
- /** @phpstan-ignore-next-line */
- $this->s3 = new Aws\S3\S3Client([
+ $s3_client_props = [
'version' => 'latest',
'region' => Config::get(self::CACHE_S3_REGION),
'endpoint' => Config::get(self::CACHE_S3_ENDPOINT),
'use_path_style_endpoint' => true,
- 'credentials' => [
+ ];
+
+ if (Config::get(self::CACHE_S3_ACCESS_KEY) && Config::get(self::CACHE_S3_SECRET_KEY)) {
+ $s3_client_props['credentials'] = [
'key' => Config::get(self::CACHE_S3_ACCESS_KEY),
- 'secret' => Config::get(self::CACHE_S3_SECRET_KEY)
- ],
- ]);
+ 'secret' => Config::get(self::CACHE_S3_SECRET_KEY),
+ ];
+ }
+
+ /** @phpstan-ignore-next-line */
+ $this->s3 = new Aws\S3\S3Client($s3_client_props);
/** @phpstan-ignore-next-line */
$this->s3->registerStreamWrapper();