A fatal error occurred v4.2.0: Illegal length modifier specified 'f' in s[np]printf call

Hello, last night I updated to 4.2.0 and then I received the following:

A fatal error occurred
The following error just broke Matomo (v4.2.0):
Illegal length modifier specified ‘f’ in s[np]printf call
in /home/matomo/domain.com/vendor/twig/twig/src/Cache/FilesystemCache.php line 61

I followed the troubleshooting guide as much as possible. For example, I disabled plugins to no avail. Another troubleshooting technique is to restart the web server however, I cannot restart my web server becuase it is on a shared platform.

I then downloaded and opened a new install locally and compared line 61 code of the file FilesystemCache.php and it matches line 61 of that file that is live. At this point I am miffed about where to look to resolve this issue.

I admit, I am not as nerdy as I would like to be with this, but I am willing to dig in, I just need some direction.

Thank you

Hi,

It would be great if you would like to get to the source of this issue. Very few people report it, but still it has been reported before:

I personally think this isn’t a bug in Matomo or even in Twig, but rather a bug in your PHP version.

This is the line of code that the error message says:

As you can see it includes no kind of call to *printf, so there can’t be an illegal modifier passed to it.

But I wouldn’t be surprised if the C code that implements file_put_contents and rename do internally use printf in a way that breaks in exactly your environment and in exactly the way Matomo uses it (as I can find few references to it outside Matomo on the internet).

My recommendation would be to upgrade your PHP to the latest patch version (so the y in 7.x.y) and see if it still occurs.

Good Evening Lukas,

Thank you for the input. I am glad you think its likely PHP. I was monkeying around with it myself. I am running PHP 7.4, but I will get in touch with the host to get the latest PHP patch 7.4.x or even PHP 8 to see if this will resolve the issue.

Again, thank you for the help.

1 Like

Hi Lukas,

I just wanted to follow up. I upgraded to PHP 8.0 and I am still receiving the error. However, this is a relatively new install (only two weeks). Also, I am using this for a personal non-profit that I am volunteering personal time to help. This non-profit is a tiny organization with zero marketing budget; so its not like I am counting tens of thousands or more of visits each day like accounts at my full time job, so its not critical. As a result I decided to do an install into a completely new directory just to start counting data again. This way when I have more time I can try to dig into to resolve. Hopefully I can post a resolution to help someone else in the future.

Kind regards

Quick advice: The bug occurs in the code that loads twig cache. So maybe try deleting everything in tmp/ to see if it fixes it.