Skip to content

Commit 5a5241d

Browse files
ENGCOM-8835: Ensure string is returned when applying filter to email template #32298
2 parents 6966362 + 767273a commit 5a5241d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ public function filter($value)
11021102
if ($this->_appState->getMode() == State::MODE_DEVELOPER) {
11031103
$value = sprintf(__('Error filtering template: %s'), $e->getMessage());
11041104
} else {
1105-
$value = __("We're sorry, an error has occurred while generating this content.");
1105+
$value = (string) __("We're sorry, an error has occurred while generating this content.");
11061106
}
11071107
$this->_logger->critical($e);
11081108
}

app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,16 @@ protected function getModel($mockedMethods = null)
267267
->getMock();
268268
}
269269

270+
/**
271+
* Test exception handling of filter method
272+
*/
273+
public function testFilterExceptionHandler()
274+
{
275+
$filter = $this->getModel();
276+
$filteredValue = $filter->filter(null);
277+
$this->assertTrue(is_string($filteredValue));
278+
}
279+
270280
/**
271281
* Test basic usages of applyInlineCss
272282
*

0 commit comments

Comments
 (0)