From 22554888b00b6299e9c9b48414f63d7c1ff49e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Ceslav=20Przywara?= Date: Wed, 7 Feb 2024 18:53:41 +0100 Subject: [PATCH] Fix Uncaught TypeError Fixes #153. --- CHANGELOG.md | 6 ++++-- .../Security/Modules/ExternalBlocklist/Settings.php | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d790b77..45652ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # BC Security Changelog -## Upcoming version 0.22.1 (????-??-??) +## Version 0.22.1 (2024-02-07) -... +### Fixed + +* Fix `Uncaught TypeError` when saving external blocklist settings [#153](https://github.com/chesio/bc-security/issues/153). ## Version 0.22.0 (2024-02-01) diff --git a/classes/BlueChip/Security/Modules/ExternalBlocklist/Settings.php b/classes/BlueChip/Security/Modules/ExternalBlocklist/Settings.php index 2f8171d..d828817 100644 --- a/classes/BlueChip/Security/Modules/ExternalBlocklist/Settings.php +++ b/classes/BlueChip/Security/Modules/ExternalBlocklist/Settings.php @@ -27,14 +27,16 @@ class Settings extends CoreSettings /** * Sanitize lock scope values. Allow only expected values. * - * @param int $value + * @internal Form data are submitted as string, so always accept string type for $value. + * + * @param int|string $value * @param int $default * * @return int */ - public static function sanitizeAccessScope(int $value, int $default): int + public static function sanitizeAccessScope(int|string $value, int $default): int { - return Scope::tryFrom($value) ? $value : $default; + return Scope::tryFrom((int) $value) ? ((int) $value) : $default; } /**