Undefined Constant Error After Switching to PHP 8.1

Not sure if this is a bug or a server configuration problem. After switching from PHP 8.0 to 8.1 on my hosting server I now get the following error email every hour when the archiving cron job runs.

ERROR [2022-12-30 13:13:01] 53120 Uncaught exception: Error: Undefined constant “Piwik\Db\Adapter\MYSQLI_OPT_LOCAL_INFILE” in /home/humming7/analytics_site/core/Db/Adapter/Mysqli.php:35
Stack trace: …

I created a very simple php file, put it at the root of my Matomo installation, and the MYSQLI_OPT_LOCAL_INFILE is definitely defined.

echo "<br>";
echo "value = ".MYSQLI_OPT_LOCAL_INFILE;

My hosting provider says they will not make any configuration changes as they impact everybody. Has anyone else had this problem? Is this a Matomo bug or a Hosting problem?

If it matters, I am using A2 Hosting Turbo Server running LiteSpeed.

Go back to php8.0 there is 0 need to have the newest PHP. Most security issues have other causes than the php version.

Its a hosting provider issue. Look for a professional set up or go VPS.

Not so sure Nickz. Why can my script read the MYSQLI_OPT_LOCAL_INFILE constant and theirs cannot?

can have many reasons, rights for once, functions which arre used in one app but not in the other. Some functions are outdated in 8.1

Thanks. I did roll back to 8.0. Using Drupal 9.5 and they recommend using PHP 8.13, which is why I switched. Site runs fine on 8.0, so I will not worry about it for now.

1 Like