codefog/contao-news_categories

Unknown format specifier "C"

rustykowski opened this issue · 6 comments

Contao 4.9.37
contao-news_categories 3.4.20 or 3.4.23
PHP 8.0 or 8.1

I get a critical error, when trying to display a newslist or news-reader:

Uncaught PHP Exception ValueError: "Unknown format specifier "C"" at /xxx/vendor/codefog/contao-news_categories/src/NewsCategoriesManager.php line 52

Could it be that you have news, pages or categories with a % in their alias?

there are several news-titles with german umlauts, such as /projekt/bildung-für-eine-starke-demokratie/ (/projekt/bildung-f%C3%BCr-eine-starke-demokratie/)

Yeah, that's the reason why sprintf will then fail.

Thanks a lot, fritzmg!

Thank you @fritzmg for debugging this. It happens because of URL caching here: https://github.com/codefog/contao-news_categories/blob/master/src/NewsCategoriesManager.php#L44-L52

I will check if it still really needs the caching in Contao 4.13 and above.

I think in Contao 5 we moved away from generating URLs via sprintf placeholders for similar reasons.