Twig icon indicating copy to clipboard operation
Twig copied to clipboard

PHP 8 and wrong input of 'format' filter breaks template rendering

Open KacerCZ opened this issue 3 years ago • 1 comments

Hi, I'm using Twig 2.14.4 with PHP 8.0.3 in CMS.

Template snippet: 'You have % z new comments' | format( newCommentCount )

If user has error in input of format filter template rendering ends with ValueError: Unknown format specifier "z" exception. PHP prior 8.0 only issued warning, returned false and rendering of template continued.

Possible solution would be to wrap sprintf call to try/catch block to prevent end of template rendering.

KacerCZ avatar Apr 28 '21 06:04 KacerCZ

To me, the actual fix is to pass valid values.

stof avatar Apr 28 '21 08:04 stof