From d3341b61c1d41ac7fa98a34b8a3c6bc14c534efe Mon Sep 17 00:00:00 2001
From: Valentin Brandl <mail+github@vbrandl.net>
Date: Thu, 24 Oct 2024 21:52:36 +0200
Subject: [PATCH] Fix initialization of `autocreate` and `use_ssl` (#2309)

According to the documentation, both `OBJECTSTORE_S3_SSL` and
`OBJECTSTORE_S3_AUTOCREATE` should default to `true`.
Currently, when these environment variables are not set, they default to
`false`. (See https://github.com/nextcloud/docker/issues/2308).

This fix works, because `strtolower(false)` returns the empty string. So
when `OBJECTSTORE_S3_SSL` is not set and `getenv('OBJECTSTORE_S3_SSL')`
returns `false`, the check `strtolower($use_ssl) !== 'false'` will
evaluate to `true`.

With this fix, both values will be `true` if they are

* not set
* the empty string
* any string that is not equal to `false` when converted to lowercase

This should now match the documented behavior.

Signed-off-by: Valentin Brandl <mail@vbrandl.net>
---
 .config/s3.config.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.config/s3.config.php b/.config/s3.config.php
index 9941c562..a17e4037 100644
--- a/.config/s3.config.php
+++ b/.config/s3.config.php
@@ -14,8 +14,8 @@ if (getenv('OBJECTSTORE_S3_BUCKET')) {
         'port' => getenv('OBJECTSTORE_S3_PORT') ?: '',
         'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '',
         'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:",
-        'autocreate' => (strtolower($autocreate) === 'false' || $autocreate == false) ? false : true,
-        'use_ssl' => (strtolower($use_ssl) === 'false' || $use_ssl == false) ? false : true,
+        'autocreate' => strtolower($autocreate) !== 'false',
+        'use_ssl' => strtolower($use_ssl) !== 'false',
         // required for some non Amazon S3 implementations
         'use_path_style' => $use_path == true && strtolower($use_path) !== 'false',
         // required for older protocol versions
-- 
GitLab