matomo
matomo copied to clipboard
Make Matomo compatible with PHP 8.2
The first alpha of PHP 8.2 has been released and I got a bit of time, so I will be looking into what the major things are that will cause current Matomo to break when using PHP 8.2. See also #17686 for 8.1
Reading through UPGRADING, I don't see any major breaking changes, but we will see what needs to be changed.
As only the first reported issue here seems to completely brake Matomo and with it fixed, the majority of Matomo is already working fine, I will only list one example per deprecated usage here and link to more information about the deprecation.
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home/lukas/public_html/matomophp8/core/testMinimumPhpVersion.php on line 130
See https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
https://github.com/matomo-org/matomo/pull/19344 (there are also a few more occurances in tests)
WARNING [2022-06-12 15:26:34] 188990 /home/lukas/public_html/matomophp8/plugins/PrivacyManager/DoNotTrackHeaderChecker.php(29): Deprecated - Creation of dynamic property Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker::$config is deprecated - Matomo 4.11.0-rc1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)
I assume this will affect a lot of code, but also it should be really easy to detect with PHPStorm or PHP_CS:
https://wiki.php.net/rfc/deprecate_dynamic_properties
https://php.watch/versions/8.2/dynamic-properties-deprecated
https://github.com/squizlabs/PHP_CodeSniffer/issues/3489
And getting rid of such cases might make the code more readable and especially avoid bugs because of typos.
WARNING [2022-06-12 15:26:35] 188990 /home/lukas/public_html/matomophp8/core/Console.php(135): Deprecated - Callables of the form ["Piwik\Console", "Symfony\Component\Console\Application::doRun"] are deprecated - Matomo 4.11.0-rc1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) https://github.com/matomo-org/matomo/blob/e3218471244d08039b1b84f1c907f1be0e018768/core/Console.php#L135
https://wiki.php.net/rfc/deprecate_partially_supported_callables https://php.watch/versions/8.2/partially-supported-callable-deprecation
To be updated...
Here is a list of additional warnings for Matomo with PHP8.2.
- WARNING: /core/Cookie.php(92): Deprecated - Creation of dynamic property Piwik\Cookie::$keyStore is deprecated - Matomo 4.11.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) (Module: CoreAdminHome, Action: home, In CLI mode: false)
- WARNING: /plugins/CustomDimensions/GetCustomDimension.php(201): Deprecated - Creation of dynamic property Piwik\Plugins\CustomDimensions\GetCustomDimension::$menuTitle is deprecated - Matomo 4.11.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) (Module: CoreAdminHome, Action: home, In CLI mode: false)
- WARNING: /plugins/CustomDimensions/GetCustomDimension.php(202): Deprecated - Creation of dynamic property Piwik\Plugins\CustomDimensions\GetCustomDimension::$widgetTitle is deprecated - Matomo 4.11.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) (Module: CoreAdminHome, Action: home, In CLI mode: false)
- WARNING: /plugins/CustomDimensions/Dimension/CustomActionDimension.php(23): Deprecated - Creation of dynamic property Piwik\Plugins\CustomDimensions\Dimension\CustomActionDimension::$actualName is deprecated - Matomo 4.11.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) (Module: CoreAdminHome, Action: home, In CLI mode: false)
- WARNING: /plugins/CustomDimensions/Dimension/CustomActionDimension.php(25): Deprecated - Creation of dynamic property Piwik\Plugins\CustomDimensions\Dimension\CustomActionDimension::$idDimension is deprecated - Matomo 4.11.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) (Module: CoreAdminHome, Action: home, In CLI mode: false)
- WARNING: /core/AssetManager/UIAssetMerger.php(183): Deprecated - Creation of dynamic property Piwik\AssetManager\UIAssetMerger\StylesheetUIAssetMerger::$cacheBusterValue is deprecated - Matomo 4.11.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) (Module: Proxy, Action: getCss, In CLI mode: false)
@utrautmann Thanks for reporting those. I've created https://github.com/matomo-org/matomo/pull/19690 to fix all of them in the next release.
Here is a list of additional warnings from latest Matomo with PHP8.2 & 4.12.2
-
[x] WARNING: /plugins/PrivacyManager/DoNotTrackHeaderChecker.php(29): Deprecated - Creation of dynamic property Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker::$config is deprecated - Matomo 4.12.2 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) (Module: UsersManager, Action: index, In CLI mode: false) = I GET this error essentially in all main menu options the only thing that changes is the Module / Location.
-
[x] WARNING: /core/Concurrency/Lock.php(95): Deprecated - Creation of dynamic property Piwik\Concurrency\Lock::$ttlUsed is deprecated - Matomo 4.12.2 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) (Module: Marketplace, Action: overview, In CLI mode: false)
thanks @JEAholding for reporting those. I'll prepare a PR to fix them.
New warning on the new upgraded head.... PHP8.2 & 4.12.3....
1.WARNING: /core/Segment/SegmentExpression.php(59): Deprecated - Creation of dynamic property Piwik\Segment\SegmentExpression::$string is deprecated - Matomo 4.12.3 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) (Module: Live, Action: getLastVisitsStart, Method: Live.getLastVisitsDetails, In CLI mode: false)
@JEAholding Added a fix for that to the other PR
Here are a few more:
-
[x] WARNING [2022-10-27 04:00:03] 21867 /var/www/html/piwik/core/ArchiveProcessor/Loader.php(70): Deprecated - Creation of dynamic property Piwik\ArchiveProcessor\Loader::$invalidateBeforeArchiving is deprecated --> https://github.com/matomo-org/matomo/pull/19918
-
[x] INFO [2022-10-27 04:10:03] 21867 'PHP Deprecated: Function utf8_encode() is deprecated in /var/www/html/piwik/vendor/szymach/c-pchart/constants.php on line 48
-
[ ] PHP Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/piwik/vendor/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php on line 52 --> possibly fixed with https://github.com/matomo-org/matomo/pull/18328
-
[ ] PHP Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/piwik/vendor/symfony/console/Symfony/Component/Console/Helper/QuestionHelper.php on line 120 --> possibly fixed with https://github.com/matomo-org/matomo/pull/18328
-
[x] PHP Deprecated: Function utf8_encode() is deprecated in /var/www/html/piwik/vendor/szymach/c-pchart/constants.php on line 48
@justinvelluppillai The first one is something we can fix. The others are caused by vendor libs, so we can only fix that with updating the libs...
Yes I see that 👍🏽
For the remaining vendor lib deprecation warning, I created an issue here: https://github.com/szymach/c-pchart/issues/86
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/problemi-con-larchiviazione-con-cron/48744/2
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/error-unserializing-during-cron-archive/48729/6
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/warnings-on-core-files-after-upgrade-to-php-8-2-0/48797/2
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/a-lot-of-warning-messages-of-deprecated/48816/4
It seems there is another kind of error, reported in the forum: https://forum.matomo.org/t/deprecated-strcmp/48832
WARNING: /core/Menu/MenuAbstract.php(367): Deprecated - strcmp(): Passing null to parameter #2 ($string2) of type string is deprecated - Matomo 4.13.0
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/deprecated-strcmp/48832/2
@heurteph-ei I've pushed a fix for that in https://github.com/matomo-org/matomo/commit/be14b703ce4e5902012d6c21d4291ce61d1847f3
Some more deprecations for PHP 8.2 (opening "All Websites" or the settings):
WARNING: /plugins/CustomDimensions/Dimension/CustomVisitDimension.php(23): Deprecated - Creation of dynamic property Piwik\Plugins\CustomDimensions\Dimension\CustomVisitDimension::$actualName 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) (Module: VisitsSummary, Action: get, In CLI mode: false)
WARNING: /plugins/CustomDimensions/Dimension/CustomVisitDimension.php(25): Deprecated - Creation of dynamic property Piwik\Plugins\CustomDimensions\Dimension\CustomVisitDimension::$idDimension 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) (Module: VisitsSummary, Action: get, In CLI mode: false)
WARNING: /core/Archive/DataCollection.php(123): Deprecated - Creation of dynamic property Piwik\Archive\DataCollection::$segment 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) (Module: API, Action: get, Method: VisitsSummary.get, In CLI mode: false)
Can confirm Matomo v4.13.0 for the core:archive Cron on PHP 8.2.0. This Notice causing the cron to report as "error" and matomo backend then reporting it didn't run.
Not happening in PHP 8.1
INFO [2023-01-04 07:59:49] 2711309 Error: Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=57&period=week&date=2022-12-26&format=json&trigger=archivephp: 'PHP Deprecated: Function utf8_encode() is deprecated in /var/www/matomo/vendor/szymach/c-pchart/constants.php on line 48 {"idarchives":[48320],"nb_visits":31}'
ERROR [2023-01-04 07:59:49] 2711309 65 total errors during this script execution, please investigate and try and fix these errors.
ERROR [2023-01-04 07:59:49] 2711309 Uncaught exception: /var/www/matomo/core/CronArchive.php(625): 65 total errors during this script execution, please investigate and try and fix these errors. [Query: , C
From: https://forum.matomo.org/t/core-archive-datacollection-php-123-deprecated/48979
- [x]
WARNING: /core/DataTable/Filter/Truncate.php(60): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$labelSummaryRow is deprecated - Matomo 4.13.0 - [x]
WARNING: /core/DataTable/Filter/Truncate.php(61): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$columnToSortByBeforeTruncating is deprecated - Matomo 4.13.0 - [x]
WARNING: /core/DataTable/Filter/Truncate.php(62): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$filterRecursive is deprecated - Matomo 4.13.0 - [x]
WARNING: /core/Plugin/Archiver.php(76): Deprecated - Creation of dynamic property Piwik\Plugins\UserId\Archiver::$maximumRows is deprecated - Matomo 4.13.0 - [x]
WARNING: /core/DataTable/Filter/Truncate.php(56): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$truncateAfter is deprecated - Matomo 4.13.0
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/core-archive-datacollection-php-123-deprecated/48979/4
@brotkrueml @heurteph-ei I've pushed fixes for the reported deprecation warnings to #20177
@solariz Your report is related to a vendor lib. It was updated in #20114 and thus the error should be fixed in the next release.
Hi @sgiehl Three new Deprecated dynamic properties found in https://forum.matomo.org/t/php-erros-after-migration-to-4-1-13-1/49220:
- [x] WARNING: /core/DataAccess/ArchiveWriter.php(102): Deprecated - Creation of dynamic property Piwik\DataAccess\ArchiveWriter::$idArchive is deprecated - Matomo 4.13.1
- [x] WARNING: /plugins/Events/Archiver.php(80): Deprecated - Creation of dynamic property Piwik\Plugins\Events\Archiver::$columnToSortByBeforeTruncation is deprecated - Matomo 4.13.1
- [x] Deprecated - Creation of dynamic property Piwik\Plugins\Events\Archiver::$maximumRowsInSubDataTable is deprecated - Matomo 4.13.1
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/php-erros-after-migration-to-4-1-13-1/49220/3
@heurteph-ei I've created a PR to fix them. I'll close this issue now. In general Matomo should already work with PHP 8.2. If any further issues are reported on the forum, please create new issues for them. That way it's a bit easier to keep track of them for us. Thanks!
Hello again @sgiehl It seems one of the reported by @Findus23 has not been fixed yet: https://forum.matomo.org/t/core-archive-datacollection-php-123-deprecated/48979/8
This issue has been mentioned on Matomo forums. There might be relevant details there:
https://forum.matomo.org/t/ancora-qualche-chiamata-deprecata-durante-il-salvataggio/49280/2
Just tried to switch to PHP 8.2 and noticed these warnings:
[Sat Jan 21 18:55:19.453052 2023] [lsapi:warn] [pid 2831069:tid 140286189504256] [client [redacted]:61721] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Tracker\VisitExcluded::$request is deprecated in [redacted]/core/Tracker/VisitExcluded.php on line 40\n, referer: [redacted]
[Sat Jan 21 18:55:19.453127 2023] [lsapi:warn] [pid 2831069:tid 140286189504256] [client [redacted]:61721] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Tracker\VisitExcluded::$idSite is deprecated in [redacted]/core/Tracker/VisitExcluded.php on line 43\n, referer: [redacted]
[Sat Jan 21 18:55:19.453167 2023] [lsapi:warn] [pid 2831069:tid 140286189504256] [client [redacted]:61721] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Tracker\VisitExcluded::$userAgent is deprecated in [redacted]/core/Tracker/VisitExcluded.php on line 50\n, referer: [redacted]
[Sat Jan 21 18:55:19.453188 2023] [lsapi:warn] [pid 2831069:tid 140286189504256] [client [redacted]:61721] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Tracker\VisitExcluded::$ip is deprecated in [redacted]/core/Tracker/VisitExcluded.php on line 51\n, referer: [redacted]
[Sat Jan 21 18:55:19.451220 2023] [lsapi:warn] [pid 2831069:tid 140286189504256] [client [redacted]:61721] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Tracker\Request::$timestamp is deprecated in [redacted]/core/Tracker/Request.php on line 75\n, referer: [redacted]
[Sat Jan 21 18:55:18.006969 2023] [lsapi:warn] [pid 2831069:tid 140286307002112] [client [redacted]:42132] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Plugins\Referrers\Columns\ReferrerUrl::$campaignNames is deprecated in [redacted]/plugins/Referrers/Columns/Base.php on line 410\n, referer: [redacted]
[Sat Jan 21 18:55:18.006993 2023] [lsapi:warn] [pid 2831069:tid 140286307002112] [client [redacted]:42132] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Plugins\Referrers\Columns\ReferrerUrl::$campaignKeywords is deprecated in [redacted]/plugins/Referrers/Columns/Base.php on line 411\n, referer: [redacted]
[Sat Jan 21 18:55:24.378796 2023] [lsapi:warn] [pid 2831069:tid 140286189504256] [client [redacted]:42132] [host [redacted]] Backend log: PHP Deprecated: Creation of dynamic property Piwik\Plugins\Actions\Actions\ActionSiteSearch::$originalUrl is deprecated in [redacted]/plugins/Actions/Actions/ActionSiteSearch.php on line 34\n, referer: [redacted]
@mackaaij , please add your new warnings to #20236 (can you confirm you use the latest version of Matomo?)