Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further PHP 8.2 compatibility improvements #19343

Closed
Findus23 opened this issue Jun 12, 2022 · 32 comments
Closed

Further PHP 8.2 compatibility improvements #19343

Findus23 opened this issue Jun 12, 2022 · 32 comments
Labels
Help wanted Beginner friendly issues Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Milestone

Comments

@Findus23
Copy link
Member

Findus23 commented Jun 12, 2022

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

#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)

call_user_func(array($self, 'Symfony\Component\Console\Application::doRun'), $input, $output);

https://wiki.php.net/rfc/deprecate_partially_supported_callables
https://php.watch/versions/8.2/partially-supported-callable-deprecation


To be updated...

@Findus23 Findus23 added Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. Help wanted Beginner friendly issues labels Jun 12, 2022
@bx80 bx80 added this to the For Prioritization milestone Jun 13, 2022
@sgiehl sgiehl changed the title Make Matomo compatible with PHP8.1 Make Matomo compatible with PHP 8.2 Jun 13, 2022
@utrautmann
Copy link

Here is a list of additional warnings for Matomo with PHP8.2.

  1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)

@sgiehl
Copy link
Member

sgiehl commented Aug 29, 2022

@utrautmann Thanks for reporting those. I've created #19690 to fix all of them in the next release.

@JEAholding
Copy link

JEAholding commented Oct 27, 2022

Here is a list of additional warnings from latest Matomo with PHP8.2 & 4.12.2

  • 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.

  • 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)

@sgiehl
Copy link
Member

sgiehl commented Oct 27, 2022

thanks @JEAholding for reporting those. I'll prepare a PR to fix them.

@JEAholding
Copy link

JEAholding commented Oct 27, 2022

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)

@sgiehl
Copy link
Member

sgiehl commented Oct 28, 2022

@JEAholding Added a fix for that to the other PR

@justinvelluppillai
Copy link
Contributor

justinvelluppillai commented Oct 31, 2022

Here are a few more:

  • 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
    --> Fix PHP8.2 deprecation messages #19918

  • 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 Updates Symfony components to 5.4.x #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 Updates Symfony components to 5.4.x #18328

  • PHP Deprecated: Function utf8_encode() is deprecated in /var/www/html/piwik/vendor/szymach/c-pchart/constants.php on line 48

@sgiehl
Copy link
Member

sgiehl commented Oct 31, 2022

@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...

@justinvelluppillai
Copy link
Contributor

Yes I see that 👍🏽

@Findus23
Copy link
Member Author

For the remaining vendor lib deprecation warning, I created an issue here: szymach/c-pchart#86

@tassoman
Copy link
Contributor

tassoman commented Dec 15, 2022

Looks like was released into v3.0.16 of c-pchart

Same error inside PHP 8.1 installation

@MatomoForumNotifications

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

@MatomoForumNotifications

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

@MatomoForumNotifications

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

@MatomoForumNotifications

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

@heurteph-ei
Copy link

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

@MatomoForumNotifications

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/deprecated-strcmp/48832/2

@sgiehl
Copy link
Member

sgiehl commented Dec 21, 2022

@heurteph-ei I've pushed a fix for that in be14b70

@brotkrueml
Copy link

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)

@solariz
Copy link

solariz commented Jan 4, 2023

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

@heurteph-ei
Copy link

heurteph-ei commented Jan 9, 2023

From: https://forum.matomo.org/t/core-archive-datacollection-php-123-deprecated/48979

  • WARNING: /core/DataTable/Filter/Truncate.php(60): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$labelSummaryRow is deprecated - Matomo 4.13.0
  • WARNING: /core/DataTable/Filter/Truncate.php(61): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$columnToSortByBeforeTruncating is deprecated - Matomo 4.13.0
  • WARNING: /core/DataTable/Filter/Truncate.php(62): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$filterRecursive is deprecated - Matomo 4.13.0
  • WARNING: /core/Plugin/Archiver.php(76): Deprecated - Creation of dynamic property Piwik\Plugins\UserId\Archiver::$maximumRows is deprecated - Matomo 4.13.0
  • WARNING: /core/DataTable/Filter/Truncate.php(56): Deprecated - Creation of dynamic property Piwik\DataTable\Filter\Truncate::$truncateAfter is deprecated - Matomo 4.13.0

@MatomoForumNotifications

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

@sgiehl
Copy link
Member

sgiehl commented Jan 9, 2023

@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.

@heurteph-ei
Copy link

heurteph-ei commented Jan 18, 2023

Hi @sgiehl
Three new Deprecated dynamic properties found in https://forum.matomo.org/t/php-erros-after-migration-to-4-1-13-1/49220:

  • WARNING: /core/DataAccess/ArchiveWriter.php(102): Deprecated - Creation of dynamic property Piwik\DataAccess\ArchiveWriter::$idArchive is deprecated - Matomo 4.13.1
  • WARNING: /plugins/Events/Archiver.php(80): Deprecated - Creation of dynamic property Piwik\Plugins\Events\Archiver::$columnToSortByBeforeTruncation is deprecated - Matomo 4.13.1
  • Deprecated - Creation of dynamic property Piwik\Plugins\Events\Archiver::$maximumRowsInSubDataTable is deprecated - Matomo 4.13.1

@MatomoForumNotifications

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

@sgiehl
Copy link
Member

sgiehl commented Jan 18, 2023

@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!

@sgiehl sgiehl closed this as completed Jan 18, 2023
@sgiehl sgiehl modified the milestones: For Prioritization, 4.13.2 Jan 18, 2023
@heurteph-ei
Copy link

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

@MatomoForumNotifications

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

@mackaaij
Copy link

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]

@heurteph-ei
Copy link

@mackaaij , please add your new warnings to #20236 (can you confirm you use the latest version of Matomo?)

@mackaaij
Copy link

Done! Concerns Matomo version: 4.13.1.

@bx80 bx80 changed the title Make Matomo compatible with PHP 8.2 Further PHP 8.2 compatiblilty improvements Jan 25, 2023
@bx80 bx80 changed the title Further PHP 8.2 compatiblilty improvements Further PHP 8.2 compatibility improvements Jan 25, 2023
@MatomoForumNotifications

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/as-signalled-added-to-forum-warning-plugins-events-archiver-php-82-deprecated/49342/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Beginner friendly issues Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Projects
None yet
Development

No branches or pull requests