From 3f8a220766bd23e860947a96e59c542a9bfb26bf Mon Sep 17 00:00:00 2001 From: Erin Dalzell Date: Fri, 11 Dec 2020 07:23:56 -0800 Subject: [PATCH] Fix join modifier when value is null (#3001) --- src/Modifiers/CoreModifiers.php | 4 ++++ tests/Modifiers/JoinTest.php | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/Modifiers/JoinTest.php diff --git a/src/Modifiers/CoreModifiers.php b/src/Modifiers/CoreModifiers.php index 24ab756c54..8c88173181 100644 --- a/src/Modifiers/CoreModifiers.php +++ b/src/Modifiers/CoreModifiers.php @@ -753,6 +753,10 @@ public function image($value, $params) */ public function joinplode($value, $params) { + if (is_null($value)) { + return ''; + } + // Workaround to support pipe characters. If there are multiple params // that means a pipe was used. We'll just join them for now. if (count($params) > 1) { diff --git a/tests/Modifiers/JoinTest.php b/tests/Modifiers/JoinTest.php new file mode 100644 index 0000000000..d3789a1cb8 --- /dev/null +++ b/tests/Modifiers/JoinTest.php @@ -0,0 +1,21 @@ +modify(null); + $this->assertEquals('', $joined); + } + + public function modify($arr, $delimiter = ' ') + { + return Modify::value($arr)->join($delimiter)->fetch(); + } +}