From a4274f7b2ee43b9ece4875c7b781f13fbcb32810 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 10:49:50 -0400 Subject: [PATCH 01/11] refactor config validation --- CHANGELOG.md | 1 + README.md | 1 + deployment/config.base.ini | 2 +- resources/lib/UnityDeployment.php | 112 +++++++++++++++++++----------- resources/lib/UnityMailer.php | 21 +----- workers/configtest.php | 6 ++ 6 files changed, 84 insertions(+), 59 deletions(-) create mode 100755 workers/configtest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c7dc052ad..876c80753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ For details on the changes in each release, see [the Releases page](https://gith - the `mail_overrides` directory has been renamed to `mail` - the `templates_overrides` directory has been renamed to `templates` - the `overrides` directory has been renamed to `domain_overrides` +- the `[smtp]ssl_verify` option has changed from `"true"/"false"` to `true/false` ### 1.6 -> 1.7 diff --git a/README.md b/README.md index 0a4c6fc1d..25bf46cbc 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ rsync -a "$prod/deployment/overrides/" ./deployment/overrides/ rsync -a "$prod/webroot/assets/footer_logos/" ./footer_logos/ rsync -a "$prod/deployment/mail/" ./deployment/mail/ rsync -a "$prod/deployment/templates/" ./deployment/templates/ +"$new/workers/configtest.php" rm "$prod" && ln -s "$PWD" "$prod" ``` diff --git a/deployment/config.base.ini b/deployment/config.base.ini index 7f8590565..bc9ee9d45 100644 --- a/deployment/config.base.ini +++ b/deployment/config.base.ini @@ -58,7 +58,7 @@ port = "1025" ; port of remote smtp server security = "" ; leave blank for no encryption, "ssl", or "tls" user = "" ; smtp username, if exists pass = "" ; smtp password, if exists -ssl_verify = "false" ; set to true to verify ssl certificates +ssl_verify = false ; set to true to verify ssl certificates [colors] light_background = "#ffffff" ; Background color when in light mode diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index c50ff0ea7..2de4f7a70 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -42,72 +42,56 @@ private static function pullConfig(array $CONFIG, string $loc): array } /** @param mixed[] $x */ - private static function doesArrayHaveOnlyIntegerValues(array $x): bool + private static function validateAllValuesAreInts(array $x, string $name): void { foreach ($x as $value) { if (!is_int($value)) { - return false; + throw new InvalidConfigurationException("all values of $name must be integers"); } } - return true; } - /** @param int[] $x */ - private static function isArrayMonotonicallyIncreasing(array $x): bool + /** @param mixed[] $x */ + private static function validateArrayIsMonotonicallyIncreasing(array $x, string $name): void { - if (count($x) <= 1) { - return true; + self::validateArrayNotEmpty($x, $name); + self::validateAllValuesAreInts($x, $name); + if (count($x) === 1) { + return; } $remaining_values = $x; $last_value = array_shift($remaining_values); while (count($remaining_values)) { $this_value = array_shift($remaining_values); if ($this_value < $last_value) { - return false; + throw new InvalidConfigurationException("$name must be monotonically increasing"); } $last_value = $this_value; } - return true; } /** @param mixed[] $CONFIG */ private static function validateConfig(array $CONFIG): void { + self::validateExpiryConfig($CONFIG); + self::validateSmtpConfig($CONFIG); + } + + /** @param mixed[] $CONFIG */ + private static function validateExpiryConfig(array $CONFIG): void + { + self::validateArrayIsMonotonicallyIncreasing( + $CONFIG["expiry"]["idlelock_warning_days"], + '$CONFIG["expiry"]["idlelock_warning_days"]', + ); + self::validateArrayIsMonotonicallyIncreasing( + $CONFIG["expiry"]["disable_warning_days"], + '$CONFIG["expiry"]["disable_warning_days"]', + ); $idlelock_warning_days = $CONFIG["expiry"]["idlelock_warning_days"]; $idlelock_day = $CONFIG["expiry"]["idlelock_day"]; $disable_warning_days = $CONFIG["expiry"]["disable_warning_days"]; $disable_day = $CONFIG["expiry"]["disable_day"]; - if (count($idlelock_warning_days) === 0) { - throw new InvalidConfigurationException( - '$CONFIG["expiry"]["idlelock_warning_days"] must not be empty!', - ); - } - if (count($disable_warning_days) === 0) { - throw new InvalidConfigurationException( - '$CONFIG["expiry"]["disable_warning_days"] must not be empty!', - ); - } - if (!self::doesArrayHaveOnlyIntegerValues($idlelock_warning_days)) { - throw new InvalidConfigurationException( - '$CONFIG["expiry"]["idlelock_warning_days"] must be a list of integers!', - ); - } - if (!self::doesArrayHaveOnlyIntegerValues($disable_warning_days)) { - throw new InvalidConfigurationException( - '$CONFIG["expiry"]["disable_warning_days"] must be a list of integers!', - ); - } - if (!self::isArrayMonotonicallyIncreasing($idlelock_warning_days)) { - throw new InvalidConfigurationException( - '$CONFIG["expiry"]["idlelock_warning_days"] must be monotonically increasing!', - ); - } - if (!self::isArrayMonotonicallyIncreasing($disable_warning_days)) { - throw new InvalidConfigurationException( - '$CONFIG["expiry"]["disable_warning_days"] must be monotonically increasing!', - ); - } - $final_disable_warning_day = _array_last($disable_warning_days); $final_idlelock_warning_day = _array_last($idlelock_warning_days); if ($disable_day <= $final_disable_warning_day) { @@ -127,6 +111,54 @@ private static function validateConfig(array $CONFIG): void } } + /** @param mixed[] $CONFIG */ + private static function validateSmtpConfig(array $CONFIG): void + { + self::validateStringNotEmpty($CONFIG["smtp"]["host"], '$CONFIG["smtp"]["host"]'); + self::validateStringNotEmpty($CONFIG["smtp"]["port"], '$CONFIG["smtp"]["port"]'); + self::validateOneOf($CONFIG["smtp"]["security"], '$CONFIG["smtp"]["security"]', [ + "", + "tls", + "ssl", + ]); + self::validateIsBool($CONFIG["smtp"]["ssl_verify"], '$CONFIG["smtp"]["ssl_verify"]'); + } + + /** @param mixed[] $x */ + private static function validateArrayNotEmpty(array $x, string $name): void + { + if (count($x) === 0) { + throw new InvalidConfigurationException("$name must not be empty"); + } + } + + private static function validateStringNotEmpty(string $x, string $name): void + { + if (empty($x)) { + throw new InvalidConfigurationException("$name must not be empty"); + } + } + + private static function validateIsBool(mixed $x, string $name): void + { + if (!is_bool($x)) { + throw new InvalidConfigurationException("$name must be a boolean"); + } + } + + /** @param mixed[] $options */ + private static function validateOneOf(string $x, string $name, array $options): void + { + foreach ($options as $option) { + if ($x === $option) { + return; + } + } + throw new InvalidConfigurationException( + sprintf("%s must be one of %s", $name, _json_encode($options)), + ); + } + private static function assertHttpHostValid(string $host): void { if (!_preg_match("/^[a-zA-Z0-9._:-]+$/", $host)) { diff --git a/resources/lib/UnityMailer.php b/resources/lib/UnityMailer.php index 3f377500a..572287684 100644 --- a/resources/lib/UnityMailer.php +++ b/resources/lib/UnityMailer.php @@ -6,7 +6,7 @@ use Exception; use Twig\TwigFunction; -class UnityMailerException extends Exception {} +class UnityMailerException extends \Exception {} /** * This is a class that uses PHPmailer to send emails based on templates @@ -38,24 +38,9 @@ public function __construct() $this->MSG_ADMIN_NAME = CONFIG["mail"]["admin_name"]; $this->MSG_PI_APPROVAL_EMAIL = CONFIG["mail"]["pi_approve"]; $this->MSG_PI_APPROVAL_NAME = CONFIG["mail"]["pi_approve_name"]; - if (empty(CONFIG["smtp"]["host"])) { - throw new Exception("SMTP server hostname not set"); - } $this->Host = CONFIG["smtp"]["host"]; - - if (empty(CONFIG["smtp"]["port"])) { - throw new Exception("SMTP server port not set"); - } $this->Port = CONFIG["smtp"]["port"]; - - $security = CONFIG["smtp"]["security"]; - $security_conf_valid = empty($security) || $security == "tls" || $security == "ssl"; - if (!$security_conf_valid) { - throw new Exception( - "SMTP security is not set correctly, leave empty, use 'tls', or 'ssl'", - ); - } - $this->SMTPSecure = $security; + $this->SMTPSecure = CONFIG["smtp"]["security"]; if (!empty(CONFIG["smtp"]["user"])) { $this->SMTPAuth = true; @@ -68,7 +53,7 @@ public function __construct() $this->Password = CONFIG["smtp"]["pass"]; } - if (CONFIG["smtp"]["ssl_verify"] == "false") { + if (CONFIG["smtp"]["ssl_verify"] === false) { $this->SMTPOptions = [ "ssl" => [ "verify_peer" => false, diff --git a/workers/configtest.php b/workers/configtest.php new file mode 100755 index 000000000..4f84b53e9 --- /dev/null +++ b/workers/configtest.php @@ -0,0 +1,6 @@ +#!/usr/bin/env php + Date: Mon, 6 Apr 2026 10:54:59 -0400 Subject: [PATCH 02/11] validate -> assert --- resources/lib/UnityDeployment.php | 88 +++++++++++++------------------ 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index 2de4f7a70..3e84f94bd 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -42,20 +42,18 @@ private static function pullConfig(array $CONFIG, string $loc): array } /** @param mixed[] $x */ - private static function validateAllValuesAreInts(array $x, string $name): void + private static function assertAllValuesAreInts(array $x, string $name): void { foreach ($x as $value) { - if (!is_int($value)) { - throw new InvalidConfigurationException("all values of $name must be integers"); - } + assert(is_int($value), "all values of $name must be integers"); } } /** @param mixed[] $x */ - private static function validateArrayIsMonotonicallyIncreasing(array $x, string $name): void + private static function assertArrayIsMonotonicallyIncreasing(array $x, string $name): void { - self::validateArrayNotEmpty($x, $name); - self::validateAllValuesAreInts($x, $name); + self::assertArrayNotEmpty($x, $name); + self::assertAllValuesAreInts($x, $name); if (count($x) === 1) { return; } @@ -63,9 +61,7 @@ private static function validateArrayIsMonotonicallyIncreasing(array $x, string $last_value = array_shift($remaining_values); while (count($remaining_values)) { $this_value = array_shift($remaining_values); - if ($this_value < $last_value) { - throw new InvalidConfigurationException("$name must be monotonically increasing"); - } + assert($this_value >= $last_value, "$name must be monotonically increasing"); $last_value = $this_value; } } @@ -73,18 +69,22 @@ private static function validateArrayIsMonotonicallyIncreasing(array $x, string /** @param mixed[] $CONFIG */ private static function validateConfig(array $CONFIG): void { - self::validateExpiryConfig($CONFIG); - self::validateSmtpConfig($CONFIG); + try { + self::validateExpiryConfig($CONFIG); + self::validateSmtpConfig($CONFIG); + } catch (AssertionError $e) { + throw new InvalidConfigurationException(previous: $e); + } } /** @param mixed[] $CONFIG */ private static function validateExpiryConfig(array $CONFIG): void { - self::validateArrayIsMonotonicallyIncreasing( + self::assertArrayIsMonotonicallyIncreasing( $CONFIG["expiry"]["idlelock_warning_days"], '$CONFIG["expiry"]["idlelock_warning_days"]', ); - self::validateArrayIsMonotonicallyIncreasing( + self::assertArrayIsMonotonicallyIncreasing( $CONFIG["expiry"]["disable_warning_days"], '$CONFIG["expiry"]["disable_warning_days"]', ); @@ -94,67 +94,51 @@ private static function validateExpiryConfig(array $CONFIG): void $disable_day = $CONFIG["expiry"]["disable_day"]; $final_disable_warning_day = _array_last($disable_warning_days); $final_idlelock_warning_day = _array_last($idlelock_warning_days); - if ($disable_day <= $final_disable_warning_day) { - throw new InvalidConfigurationException( - "disable day must be greater than the last disable warning day", - ); - } - if ($idlelock_day <= $final_idlelock_warning_day) { - throw new InvalidConfigurationException( - "idlelock day must be greater than the last idlelock warning day", - ); - } - if ($disable_day <= $idlelock_day) { - throw new InvalidConfigurationException( - "disable day must be greater than idlelock day", - ); - } + assert( + $disable_day > $final_disable_warning_day, + "disable day must be greater than the last disable warning day", + ); + assert( + $idlelock_day > $final_idlelock_warning_day, + "idlelock day must be greater than the last idlelock warning day", + ); + assert($disable_day > $idlelock_day, "disable day must be greater than idlelock day"); } /** @param mixed[] $CONFIG */ private static function validateSmtpConfig(array $CONFIG): void { - self::validateStringNotEmpty($CONFIG["smtp"]["host"], '$CONFIG["smtp"]["host"]'); - self::validateStringNotEmpty($CONFIG["smtp"]["port"], '$CONFIG["smtp"]["port"]'); - self::validateOneOf($CONFIG["smtp"]["security"], '$CONFIG["smtp"]["security"]', [ + self::assertStringNotEmpty($CONFIG["smtp"]["host"], '$CONFIG["smtp"]["host"]'); + self::assertStringNotEmpty($CONFIG["smtp"]["port"], '$CONFIG["smtp"]["port"]'); + self::assertOneOf($CONFIG["smtp"]["security"], '$CONFIG["smtp"]["security"]', [ "", "tls", "ssl", ]); - self::validateIsBool($CONFIG["smtp"]["ssl_verify"], '$CONFIG["smtp"]["ssl_verify"]'); + self::assertIsBool($CONFIG["smtp"]["ssl_verify"], '$CONFIG["smtp"]["ssl_verify"]'); } /** @param mixed[] $x */ - private static function validateArrayNotEmpty(array $x, string $name): void + private static function assertArrayNotEmpty(array $x, string $name): void { - if (count($x) === 0) { - throw new InvalidConfigurationException("$name must not be empty"); - } + assert(count($x) > 0, "$name must not be empty"); } - private static function validateStringNotEmpty(string $x, string $name): void + private static function assertStringNotEmpty(string $x, string $name): void { - if (empty($x)) { - throw new InvalidConfigurationException("$name must not be empty"); - } + assert(!empty($x), "$name must not be empty"); } - private static function validateIsBool(mixed $x, string $name): void + private static function assertIsBool(mixed $x, string $name): void { - if (!is_bool($x)) { - throw new InvalidConfigurationException("$name must be a boolean"); - } + assert(is_bool($x), "$name must be a boolean"); } /** @param mixed[] $options */ - private static function validateOneOf(string $x, string $name, array $options): void + private static function assertOneOf(string $x, string $name, array $options): void { - foreach ($options as $option) { - if ($x === $option) { - return; - } - } - throw new InvalidConfigurationException( + assert( + in_array($x, $options, true), sprintf("%s must be one of %s", $name, _json_encode($options)), ); } From 26c31762fae81c58d666739f62702b3366e00cbc Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 10:56:59 -0400 Subject: [PATCH 03/11] refactor --- resources/lib/UnityDeployment.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index 3e84f94bd..24a785323 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -80,18 +80,18 @@ private static function validateConfig(array $CONFIG): void /** @param mixed[] $CONFIG */ private static function validateExpiryConfig(array $CONFIG): void { + $idlelock_warning_days = $CONFIG["expiry"]["idlelock_warning_days"]; + $idlelock_day = $CONFIG["expiry"]["idlelock_day"]; + $disable_warning_days = $CONFIG["expiry"]["disable_warning_days"]; + $disable_day = $CONFIG["expiry"]["disable_day"]; self::assertArrayIsMonotonicallyIncreasing( - $CONFIG["expiry"]["idlelock_warning_days"], + $idlelock_warning_days, '$CONFIG["expiry"]["idlelock_warning_days"]', ); self::assertArrayIsMonotonicallyIncreasing( - $CONFIG["expiry"]["disable_warning_days"], + $disable_warning_days, '$CONFIG["expiry"]["disable_warning_days"]', ); - $idlelock_warning_days = $CONFIG["expiry"]["idlelock_warning_days"]; - $idlelock_day = $CONFIG["expiry"]["idlelock_day"]; - $disable_warning_days = $CONFIG["expiry"]["disable_warning_days"]; - $disable_day = $CONFIG["expiry"]["disable_day"]; $final_disable_warning_day = _array_last($disable_warning_days); $final_idlelock_warning_day = _array_last($idlelock_warning_days); assert( From 7cd7fd5acfdcd4750251d55e067e6e312e0ff8aa Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 11:05:45 -0400 Subject: [PATCH 04/11] specific func name --- resources/lib/UnityDeployment.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index 24a785323..9a7d1e674 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -50,8 +50,10 @@ private static function assertAllValuesAreInts(array $x, string $name): void } /** @param mixed[] $x */ - private static function assertArrayIsMonotonicallyIncreasing(array $x, string $name): void - { + private static function assertArrayIsOneOrMoreMonotonicallyIncreasingIntegers( + array $x, + string $name, + ): void { self::assertArrayNotEmpty($x, $name); self::assertAllValuesAreInts($x, $name); if (count($x) === 1) { @@ -84,11 +86,11 @@ private static function validateExpiryConfig(array $CONFIG): void $idlelock_day = $CONFIG["expiry"]["idlelock_day"]; $disable_warning_days = $CONFIG["expiry"]["disable_warning_days"]; $disable_day = $CONFIG["expiry"]["disable_day"]; - self::assertArrayIsMonotonicallyIncreasing( + self::assertArrayIsOneOrMoreMonotonicallyIncreasingIntegers( $idlelock_warning_days, '$CONFIG["expiry"]["idlelock_warning_days"]', ); - self::assertArrayIsMonotonicallyIncreasing( + self::assertArrayIsOneOrMoreMonotonicallyIncreasingIntegers( $disable_warning_days, '$CONFIG["expiry"]["disable_warning_days"]', ); From ea90713115ab1b0496d3113c17ac2e4c4a2d5b42 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 11:09:05 -0400 Subject: [PATCH 05/11] fix require --- workers/configtest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/configtest.php b/workers/configtest.php index 4f84b53e9..eaf6b3a9d 100755 --- a/workers/configtest.php +++ b/workers/configtest.php @@ -1,6 +1,6 @@ #!/usr/bin/env php Date: Mon, 6 Apr 2026 11:11:35 -0400 Subject: [PATCH 06/11] simplify configtest --- workers/configtest.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/workers/configtest.php b/workers/configtest.php index eaf6b3a9d..911ad1a3b 100755 --- a/workers/configtest.php +++ b/workers/configtest.php @@ -1,6 +1,2 @@ #!/usr/bin/env php - Date: Mon, 6 Apr 2026 11:15:19 -0400 Subject: [PATCH 07/11] mask AssertionError --- resources/lib/UnityDeployment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index 9a7d1e674..13be543c9 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -75,7 +75,7 @@ private static function validateConfig(array $CONFIG): void self::validateExpiryConfig($CONFIG); self::validateSmtpConfig($CONFIG); } catch (AssertionError $e) { - throw new InvalidConfigurationException(previous: $e); + throw new InvalidConfigurationException($e->getMessage()); } } From b8868e6c1778d4107dc2e11f536756595c9dd712 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 11:17:16 -0400 Subject: [PATCH 08/11] require zend.assertions --- resources/lib/UnityDeployment.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index 13be543c9..c6a0220e7 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -71,6 +71,9 @@ private static function assertArrayIsOneOrMoreMonotonicallyIncreasingIntegers( /** @param mixed[] $CONFIG */ private static function validateConfig(array $CONFIG): void { + if (ini_get("zend.assertions") !== "1") { + throw new InvalidConfigurationException("zend.assertions must be set to 1"); + } try { self::validateExpiryConfig($CONFIG); self::validateSmtpConfig($CONFIG); From c460a3148c7f69c5f82866ddda6d8c5a62e837af Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 11:28:45 -0400 Subject: [PATCH 09/11] require assert.exception --- resources/lib/UnityDeployment.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index c6a0220e7..75979f125 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -74,6 +74,9 @@ private static function validateConfig(array $CONFIG): void if (ini_get("zend.assertions") !== "1") { throw new InvalidConfigurationException("zend.assertions must be set to 1"); } + if (ini_get("assert.exception") !== "1") { + throw new InvalidConfigurationException("assert.exception must be set to 1"); + } try { self::validateExpiryConfig($CONFIG); self::validateSmtpConfig($CONFIG); From cc7c7a82abcba9c5bc47b23b5d5651e4211731e6 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 11:29:01 -0400 Subject: [PATCH 10/11] catch any throwable --- resources/lib/UnityDeployment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index 75979f125..5383ea67c 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -80,7 +80,7 @@ private static function validateConfig(array $CONFIG): void try { self::validateExpiryConfig($CONFIG); self::validateSmtpConfig($CONFIG); - } catch (AssertionError $e) { + } catch (\Throwable $e) { throw new InvalidConfigurationException($e->getMessage()); } } From 1707ec91d08170a5cca225a7e3da763075f761c4 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Mon, 6 Apr 2026 11:29:10 -0400 Subject: [PATCH 11/11] smtp port is int --- CHANGELOG.md | 2 +- deployment/config.base.ini | 2 +- resources/lib/UnityDeployment.php | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 876c80753..bd3994207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ For details on the changes in each release, see [the Releases page](https://gith - the `mail_overrides` directory has been renamed to `mail` - the `templates_overrides` directory has been renamed to `templates` - the `overrides` directory has been renamed to `domain_overrides` -- the `[smtp]ssl_verify` option has changed from `"true"/"false"` to `true/false` +- the `ssl_verify` and `port` options in the `smtp` config section should have quotes removed ### 1.6 -> 1.7 diff --git a/deployment/config.base.ini b/deployment/config.base.ini index bc9ee9d45..9219bd510 100644 --- a/deployment/config.base.ini +++ b/deployment/config.base.ini @@ -54,7 +54,7 @@ dbname = "unity" ; mariadb database name [smtp] host = "smtp" ; hostname of remote smtp server -port = "1025" ; port of remote smtp server +port = 1025 ; port of remote smtp server security = "" ; leave blank for no encryption, "ssl", or "tls" user = "" ; smtp username, if exists pass = "" ; smtp password, if exists diff --git a/resources/lib/UnityDeployment.php b/resources/lib/UnityDeployment.php index 5383ea67c..9f58fff34 100644 --- a/resources/lib/UnityDeployment.php +++ b/resources/lib/UnityDeployment.php @@ -117,7 +117,7 @@ private static function validateExpiryConfig(array $CONFIG): void private static function validateSmtpConfig(array $CONFIG): void { self::assertStringNotEmpty($CONFIG["smtp"]["host"], '$CONFIG["smtp"]["host"]'); - self::assertStringNotEmpty($CONFIG["smtp"]["port"], '$CONFIG["smtp"]["port"]'); + self::assertIsInt($CONFIG["smtp"]["port"], '$CONFIG["smtp"]["port"]'); self::assertOneOf($CONFIG["smtp"]["security"], '$CONFIG["smtp"]["security"]', [ "", "tls", @@ -142,6 +142,11 @@ private static function assertIsBool(mixed $x, string $name): void assert(is_bool($x), "$name must be a boolean"); } + private static function assertIsInt(mixed $x, string $name): void + { + assert(is_int($x), "$name must be a boolean"); + } + /** @param mixed[] $options */ private static function assertOneOf(string $x, string $name, array $options): void {