Error Unserializing During CRON Archive

Matomo V 4.13.0
MySQL version: 10.3.36-MariaDB-0+deb10u2
PHP version: 8.1.13

Since a recent PHP update we are now getting these errors after cron runs every hour:

PHP Deprecated: Function utf8_encode() is deprecated in /path-to-matomo/example.com/public_html/vendor/szymach/c-pchart/constants.php on line 48
ERROR [2022-12-13 19:05:12] 28748 Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=2&period=day&date=2022-12-13&format=json&trigger=archivephp: ‘PHP Deprecated: Function utf8_encode() is deprecated in /path-to-matomo/example.com/public_html/vendor/szymach/c-pchart/constants.php on line 48 {“idarchives”:[23261],“nb_visits”:4}’
ERROR [2022-12-13 19:05:12] 28748 Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=2&period=day&date=2022-12-12&format=json&trigger=archivephp: ‘PHP Deprecated: Function utf8_encode() is deprecated in /path-to-matomo/example.com/public_html/vendor/szymach/c-pchart/constants.php on line 48 {“idarchives”:[22581],“nb_visits”:29}’
ERROR [2022-12-13 19:05:12] 28748 Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=2&period=day&date=2022-12-11&format=json&trigger=archivephp: ‘PHP Deprecated: Function utf8_encode() is deprecated in /path-to-matomo/example.com/public_html/vendor/szymach/c-pchart/constants.php on line 48 {“idarchives”:[20181],“nb_visits”:6}’
ERROR [2022-12-13 19:05:16] 28748 Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=2&period=week&date=2022-12-12&format=json&trigger=archivephp: ‘PHP Deprecated: Function utf8_encode() is deprecated in /path-to-matomo/example.com/public_html/vendor/szymach/c-pchart/constants.php on line 48 {“idarchives”:[23266],“nb_visits”:33}’

[Exception]
62 total errors during this script execution, please investigate and try and fix these errors.

core:archive [–url="…"] [–skip-idsites[="…"]] [–skip-all-segments] [–force-idsites[="…"]] [–skip-segments-today] [–force-periods[="…"]] [–force-date-last-n[="…"]] [–force-date-range[="…"]] [–force-idsegments="…"] [–concurrent-requests-per-website[="…"]] [–concurrent-archivers[="…"]] [–max-websites-to-process="…"] [–max-archives-to-process="…"] [–disable-scheduled-tasks] [–accept-invalid-ssl-certificate] [–php-cli-options[="…"]] [–force-all-websites] [–force-report[="…"]]

INFO [2022-12-13 20:47:35] 24415 Error: Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=26&period=month&date=2022-12-01&format=json&trigger=archivephp: ‘PHP Deprecated: Function utf8_encode() is deprecated in /home/roguevalleymedia/domains/analytics.roguevalleymedia.com/public_html/vendor/szymach/c-pchart/constants.php on line 48 {“idarchives”:[23501],“nb_visits”:24}’

Cron =
/usr/bin/php /path-to-matomo/example.com/public_html/console core:archive --url=https://example.com/ > /dev/null

We also tried this Cron:
/usr/bin/php /path-to-matomo/example.com/public_html/console --matomo-domain=example.com core:archive

Any help or suggestions are appreciated.

Same here ;-(
I am using
Matomo-Version: 4.13.0
MySQL-Version: 10.3.36-MariaDB-0+deb10u2
PHP-Version: 7.4.33

update-alternatives --config php - to select the php version I am using worked for me ! Cronjob and Webversion where different - now they are the same again.

@SaschaGresk - Not sure I understood your reply. Did you resolve your errors? If so, how?

We were using PHP 8.1 for months and all was well. We only started getting these errors after some recent PHP updates. The server is Debian 10.

same Problem
PHP 7.4.3
Matomo 4.13.0

PHP Deprecated: Function utf8_encode() is deprecated in /data/www/piwik/vendor/szymach/c-pchart/constants.php on line 48
ERROR [2022-12-16 07:31:02] 3202 Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2022-12-16&format=json&trigger=archivephp: 'PHP Deprecated: Function utf8_encode() is deprecated in …

Seems to be a problem in
/* Euro symbol for GD fonts */
define(“EURO_SYMBOL”, utf8_encode("& # 8364;"));

Maybe this will help if utf8_encode is really needed

/* Euro symbol for GD fonts */
define(“EURO_SYMBOL”, mb_convert_encoding(’& # 8364;’, ‘UTF-8’, ‘ISO-8859-1’));

Please remove the spaces “& # 8364”

Hi @fun4us, @jtomelevage, @SaschaGresk.
See GitHub ticket:

@fun4us - There are no spaces in my line 48:

define("EURO_SYMBOL", utf8_encode("€"));

Sorry, as i wrote “& # 8364” without spaces in my post the € sign was displayed. So i have added spaces betwenn “& # 8”. This should actually be removed.

So as a test I remmed out line 48

/* define("EURO_SYMBOL", utf8_encode("€")); */

After this the cron job appears to run “mostly well” with this new message at the top:

WARNING [2022-12-16 17:50:09] 28480  /path-to-matomo/core/Console.php(135): Deprecated - Callables of the form ["Piwik\Console", "Symfony\Component\Console\Application::doRun"] are deprecated - Matomo 4.13.0 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)
WARNING [2022-12-16 17:50:09] 28480  /path-to-matomo/core/CronArchive.php(251): Deprecated - Creation of dynamic property Piwik\CronArchive::$rawLogDao is deprecated - Matomo 4.13.0 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)
INFO [2022-12-16 17:50:11] 28480  ---------------------------

Additionally, I see this message in the Matomo backend under Diagnostic | System Check

Errors below may be due to a partial or failed upload of Matomo files.
--> Try to reupload all the Matomo files in BINARY mode. <--

File size mismatch: /path-to-matomo/vendor/szymach/c-pchart/constants.php (expected length: 5999, found: 6005)

I’m sure this has to do with my commenting out line 48.

This seem like a bad way to fix this issue. Better ideas, or a real solution, are appreciated.

Ho, i addded
define(“EURO_SYMBOL”, mb_convert_encoding(’&#8364;’, ‘UTF-8’, ‘ISO-8859-1’));
and the error is gone. I have the same warnings like you have.

@fun4us - I’m in the US so I don’t know, and cannot recall, that I ever saw the Euro symbol anywhere. That being said I will try your code and see what happens.

When you say you are getting the same warnings do you mean these:

"Piwik\Console", "Symfony\Component\Console\Application::doRun"

Or the warnings that the file sizes mismatch?

WARNING [2022-12-17 15:31:01] 27533 /data/www/htdocs/piwik/core/Console.php(135): Deprecated - Callables of the form [“Piwik\Console”, “Symfony\Component\Console\Application::doRun”] are deprecated - Matomo 4.13.0 - Please report this message in
WARNING [2022-12-17 15:31:01] 27533 /data/www/htdocs/piwik/core/CronArchive.php(251): Deprecated - Creation of dynamic property Piwik\CronArchive::$rawLogDao is deprecated - Matomo 4.13.0 - Please report this message in the Matomo forums: https:/

I also found the other Error
Unterschiedliche Dateigröße: /data/www/mineralienatlas/htdocs/analyse/piwik/vendor/szymach/c-pchart/constants.php (erwartete Größe: 5999, gefunden: 6083) seems to be because of the changes

@fun4us - I tried your code and got these errors:

PHP Fatal error:  Uncaught Error: Undefined constant "“EURO_SYMBOL”" in /home/roguevalleymedia/domains/analytics.roguevalleymedia.com/public_html/vendor/szymach/c-pchart/constants.php:49
Stack trace:
#0 /path-to-matomo/vendor/composer/autoload_real.php(57): require()
#1 /path-to-matomo/vendor/composer/autoload_real.php(40): composerRequire50ade8048longnumberobfuscated0cb0a14()
#2 /path-to-matomo/vendor/autoload.php(25): ComposerAutoloaderInit50adlongnumberobfuscatedb0a14::getLoader()
#3 /path-to-matomo/public_html/core/bootstrap.php(44): require_once('...')
#4 /path-to-matomo/public_html/console(18): require_once('...')
#5 {main}
  thrown in /path-to-matomo/vendor/szymach/c-pchart/constants.php on line 49

It now says line 49, but that is just because I kept the original line (48) remmed out and inserted your code afterwards (line 49).