EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Replace many scalar replacement
Yuriif15708caa965
diff --git a/application/Espo/Core/Formula/Functions/StringGroup/ReplaceManyType.php b/application/Espo/Core/Formula/Functions/StringGroup/ReplaceManyType.phpindex 252d053cc2..f115557135 100644--- a/application/Espo/Core/Formula/Functions/StringGroup/ReplaceManyType.php+++ b/application/Espo/Core/Formula/Functions/StringGroup/ReplaceManyType.php@@ -64,6 +64,12 @@ class ReplaceManyType implements Functhrow BadArgumentValue::create(2, "Replacement strings must be scalar.");}+ if (is_bool($v)) {+ $v = $v ? 'true' : 'false';+ } else if ($v === null) {+ $v = 'null';+ }+$pairs[$k] = (string) $v;}diff --git a/tests/unit/Espo/Core/Formula/EvaluatorTest.php b/tests/unit/Espo/Core/Formula/EvaluatorTest.phpindex a235be30b5..f2edfaad43 100644--- a/tests/unit/Espo/Core/Formula/EvaluatorTest.php+++ b/tests/unit/Espo/Core/Formula/EvaluatorTest.php@@ -373,15 +373,19 @@ class EvaluatorTest extends TestCase\$map['0'] = 'zero';\$map['true'] = 'TRUE';\$map['false'] = 'FALSE';+ \$map['{scalarInt}'] = 1;+ \$map['{scalarTrue}'] = true;+ \$map['{scalarFalse}'] = false;+ \$map['{scalarNull}'] = null;- \$input = "Test {one} {two} 3 0 true false.";+ \$input = "Test {one} {two} 3 0 true false {scalarInt} {scalarTrue} {scalarFalse} {scalarNull}.";string\\replaceMany(\$input, \$map);EOF;$actual = $this->evaluator->process($expression);- $this->assertEquals('Test one two three zero TRUE FALSE.', $actual);+ $this->assertEquals('Test one two three zero TRUE FALSE 1 true false null.', $actual);}public function testStringReplaceManyError1(): void