From e7a3c5af9bb88237935a094e5836405094ff0894 Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Mon, 4 Nov 2024 11:51:35 +0100 Subject: [PATCH] Refactor `getInts` to explicitly set split `Limit` in `preg_split` - Set `-1` as the limit in `preg_split` within the `getInts` method to explicitly prevent a split limit, According to [w3schools documentation](https://www.w3schools.com/php/func_regex_preg_split.asp), `-1` is the default limit. However, this was not working... Considered using `explode` for simplicity but retained `preg_split` for its whitespace-trimming capability. This ensures consistent handling of branch IDs that may include extra spaces around separators (e.g., "18 , 24"). --- web/modules/custom/drupal_typed/src/RequestTyped.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/modules/custom/drupal_typed/src/RequestTyped.php b/web/modules/custom/drupal_typed/src/RequestTyped.php index 554de896a..d97aa955e 100644 --- a/web/modules/custom/drupal_typed/src/RequestTyped.php +++ b/web/modules/custom/drupal_typed/src/RequestTyped.php @@ -87,7 +87,7 @@ public function getInts(string $key, array $default = [], string $separator = ", if ($value === NULL) { return $default; } - $strings = \Safe\preg_split("/\s*{$separator}\s*/", $value, PREG_SPLIT_NO_EMPTY); + $strings = \Safe\preg_split("/\s*{$separator}\s*/", $value, -1, PREG_SPLIT_NO_EMPTY); return array_map(fn($value) => intval($value), $strings); }