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

Make Matomo compatible with PHP8.1 #17686

Closed
38 tasks done
Findus23 opened this issue Jun 17, 2021 · 31 comments
Closed
38 tasks done

Make Matomo compatible with PHP8.1 #17686

Findus23 opened this issue Jun 17, 2021 · 31 comments
Assignees
Labels
Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. 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 17, 2021

The first alpha of php8.1 was just released:
https://www.php.net/archive/2021.php#2021-06-10-1

There are a few breaking changes, so it might be useful to already start fixing things to get them released in time.

Changes: https://github.com/php/php-src/blob/php-8.1.0alpha1/UPGRADING

The major breaking change is that built-in functions now (just like user-defined functions) no longer accept null in non-nullable arguments:
https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg


Click to show fixed issues
  • monolog datetime

Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /home/lukas/public_html/matomophp8/vendor/monolog/monolog/src/Monolog/Logger.php on line 324


  • glob in upgradephp

WARNING [2021-06-17 21:51:48] 298624 /home/lukas/public_html/matomophp8/libs/upgradephp/upgrade.php(260): Deprecated - glob(): Passing null to parameter #2 ($flags) of type int is deprecated - Matomo 4.0.0-b3 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)


  • db logging string instead of array

WARNING [2021-06-17 22:11:46] 311625 /home/lukas/public_html/matomophp8/core/Db.php(829): Warning - foreach() argument must be of type array|object, string given - Matomo 4.4.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)


  • PDO fetch default

WARNING [2021-06-17 22:27:06] 321855 /home/lukas/public_html/matomophp8/libs/Zend/Db/Statement/Pdo.php(257): Deprecated - PDOStatement::fetch(): Passing null to parameter #2 ($cursorOrientation) of type int is deprecated - Matomo 4.4.0-b1 - 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 [2021-06-17 22:28:30] 322336 /home/lukas/public_html/matomophp8/libs/Zend/Db/Statement/Pdo.php(257): Deprecated - PDOStatement::fetch(): Passing null to parameter #3 ($cursorOffset) of type int is deprecated - Matomo 4.4.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)


  • null site id

WARNING [2021-06-18 08:20:57] 24637 /home/lukas/public_html/matomophp8/core/Site.php(433): Deprecated - explode(): Passing null to parameter #2 ($string) of type string is deprecated - Matomo 4.4.0-b1 - 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 [2021-06-18 08:24:50] 25583 /home/lukas/public_html/matomophp8/plugins/CoreConsole/Commands/CoreArchiver.php(59): Deprecated - explode(): Passing null to parameter #2 ($string) of type string is deprecated - Matomo 4.4.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)


  • strtoupper null

WARNING [2021-06-18 11:15:28] 107661 /home/lukas/public_html/matomophp8/plugins/GeoIp2/LocationProvider/GeoIp2/Php.php(256): Deprecated - strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated - Matomo 4.4.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)


  • substr_count null

WARNING [2021-06-18 11:15:28] 107661 /home/lukas/public_html/matomophp8/core/Access.php(164): Deprecated - substr_count(): Passing null to parameter #1 ($haystack) of type string is deprecated - Matomo 4.4.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)


  • more null during tracking

PHP Deprecated: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lukas/public_html/matomophp8/plugins/Referrers/Columns/Base.php on line 499
PHP Deprecated: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lukas/public_html/matomophp8/plugins/Referrers/Columns/Base.php on line 635
PHP Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lukas/public_html/matomophp8/plugins/Referrers/Columns/Base.php on line 313
PHP Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lukas/public_html/matomophp8/plugins/Referrers/SearchEngine.php on line 269


  • core/ArchiveProcessor.php(320)

Deprecated - round(): Passing null to parameter #1 ($num) of type int|float is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/core/ArchiveProcessor.php(320)
$2/core/ArchiveProcessor.php(304)
$3/core/ArchiveProcessor/PluginsArchiver.php(289)
$4/core/ArchiveProcessor/PluginsArchiver.php(102)
$5/core/ArchiveProcessor/Loader.php(212)
$6/core/ArchiveProcessor/Loader.php(158)
$7/core/ArchiveProcessor/Loader.php(101)
$8/core/Context.php(75)
$9/core/ArchiveProcessor/Loader.php(105)

$value = round($value, 2);


  • core/Common.php(423)

Deprecated - htmlspecialchars_decode(): Passing null to parameter #1 ($string) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/core/Common.php(423)
$2/plugins/Referrers/VisitorDetails.php(58)
$3/plugins/Referrers/VisitorDetails.php(23)
$4/plugins/Live/Visitor.php(39)
$5/plugins/Live/API.php(343)
[internal function]: Piwik\Plugins\Live\API->Piwik\Plugins\Live{closure}()
$7/core/DataTable.php(512)
$8/core/DataTable.php(618)
$9/core/API/DataTablePostProcessor.php(303)

return htmlspecialchars_decode($value, self::HTML_ENCODING_QUOTE_STYLE);


  • core/Common.php(459)

Deprecated - str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/core/Common.php(459)
$2/core/Common.php(381)
$3/plugins/Diagnostics/Diagnostic/DiagnosticResult.php(73)
$4/plugins/Diagnostics/Diagnostic/ArchiveInvalidationsInformational.php(45)
$5/plugins/Diagnostics/DiagnosticService.php(68)
$6/plugins/Diagnostics/DiagnosticService.php(55)
$7/plugins/Installation/Controller.php(494)
[internal function]: Piwik\Plugins\Installation\Controller->systemCheckPage()
$9/core/FrontController.php(619)

return str_replace(array("\n", "\r"), '', $value);


  • core/Translation/Translator.php(89)+(97)

Deprecated - strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/core/Translation/Translator.php(89)
$2/core/Piwik.php(854)
$3/plugins/API/ProcessedReport.php(232)
$4/plugins/API/ProcessedReport.php(51)
$5/plugins/API/ProcessedReport.php(342)
$6/plugins/API/API.php(287)
[internal function]: Piwik\Plugins\API\API->getProcessedReport()
$8/core/API/Proxy.php(244)
$9/core/Context.php(28)

if (strpos($translationId, "_") !== false) {


  • core/Twig.php(57)

Deprecated - str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/core/Twig.php(57)
$2/core/Twig.php(74)
$3/tmp/templates_c/7d/7db4ec1e91f63df5116d7b66dd6777405f533f5a60a0b2517aaedccadb6d2b4a.php(144)
$4/vendor/twig/twig/src/Template.php(171)
$5/tmp/templates_c/ff/ff096956e9aa11f9753b91bdaba6866a4c4a38661c94d433eef362e1f21a3c64.php(157)
$6/vendor/twig/twig/src/Template.php(171)
$7/tmp/templates_c/9d/9d0a4a6b0b07f521040aefe6c6155bdda67bc8d9638dac5549c0e0ec63edef20.php(195)
$8/vendor/twig/twig/src/Template.php(171)
$9/vendor/twig/twig/src/Template.php(134)

$replacedString = str_replace($search, $replace, $string);

  • Update PHPMailer to at least 6.5.1 (first version with provisional support for PHP 8.1)

  • Iterators

/home/lukas/public_html/matomophp8/libs/Zend/Db/Statement/Pdo.php(267): Deprecated - Return type of Zend_Db_Statement_Pdo::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

  • I think this one wasn't there before in the last alpha
  • /**
    * Required by IteratorAggregate interface
    *
    * @return IteratorIterator
    */
    public function getIterator()
    {
    return new IteratorIterator($this->_stmt);
    }
  • I think PhpStorm complains that $this->_stmt which can be null is not Traversable.

  • core/DataTable.php(1979) + same in (1984),(1991),(1996),(2001)

Deprecated - Return type of Piwik\DataTable::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
$0/core/DataTable.php(168)
$1/vendor/composer/ClassLoader.php(476)
$2/vendor/composer/ClassLoader.php(344)
$3/core/DataTable/Simple.php(21)
$4/vendor/composer/ClassLoader.php(476)
$5/vendor/composer/ClassLoader.php(344)
$6/core/API/ApiRenderer.php(63)
$7/core/API/ResponseBuilder.php(124)
$8/core/API/Request.php(272)
$9/core/Context.php(28)

public function getIterator()


  • core/DataTable/Filter/AddColumnsProcessedMetrics.php(73)

Deprecated - Automatic conversion of false to array is deprecated
$0/core/DataTable/Filter/AddColumnsProcessedMetrics.php(73)
$1/core/DataTable.php(533)
$2/core/API/DataTablePostProcessor.php(257)
$3/core/API/DataTablePostProcessor.php(218)
$4/core/API/DataTablePostProcessor.php(121)
$5/core/API/ResponseBuilder.php(190)
$6/core/API/ResponseBuilder.php(104)
$7/core/API/Request.php(272)
$8/core/Context.php(28)
$9/core/API/Request.php(273)

$extraProcessedMetrics[] = new ConversionRate();


  • libs/Zend/Session/Namespace.php(210)

Deprecated - Return type of Zend_Session_Namespace::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
$0/libs/Zend/Session/Namespace.php(44)
$1/vendor/composer/ClassLoader.php(476)
$2/vendor/composer/ClassLoader.php(344)
$3/core/Session/SessionNamespace.php(19)
$4/vendor/composer/ClassLoader.php(476)
$5/vendor/composer/ClassLoader.php(344)
$6/core/Notification/Manager.php(194)
$7/core/Notification/Manager.php(138)
$8/core/Notification/Manager.php(45)
$9/plugins/DiagnosticsExtended/DiagnosticsExtended.php(66)

public function getIterator()


  • plugins/Actions/Reports/GetPageTitles.php(77)

Deprecated - version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/Actions/Reports/GetPageTitles.php(77)
$2/core/Plugin/ViewDataTable.php(239)
$3/core/Plugin/Visualization.php(177)
$4/core/ViewDataTable/Factory.php(243)
$5/core/ViewDataTable/Factory.php(156)
$6/core/Plugin/Report.php(318)
$7/plugins/CoreHome/Controller.php(59)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget()
$9/core/FrontController.php(619)

if (version_compare(DbHelper::getInstallVersion(),'4.0.0-b1', '<')) {


  • plugins/Actions/Reports/GetPageUrls.php(75)

Deprecated - version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/Actions/Reports/GetPageUrls.php(75)
$2/core/Plugin/ViewDataTable.php(239)
$3/core/Plugin/Visualization.php(177)
$4/core/ViewDataTable/Factory.php(243)
$5/core/ViewDataTable/Factory.php(156)
$6/core/Plugin/Report.php(318)
$7/plugins/CoreHome/Controller.php(59)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget()
$9/core/FrontController.php(619)

if (version_compare(DbHelper::getInstallVersion(),'4.0.0-b1', '<')) {


  • plugins/DevicePlugins/API.php(89)

Deprecated - Automatic conversion of false to array is deprecated
$0/plugins/DevicePlugins/API.php(89)
[internal function]: Piwik\Plugins\DevicePlugins\API->getPlugin()
$2/core/API/Proxy.php(244)
$3/core/Context.php(28)
$4/core/API/Proxy.php(335)
$5/core/API/Request.php(266)
$6/plugins/API/ProcessedReport.php(378)
$7/plugins/API/API.php(287)
[internal function]: Piwik\Plugins\API\API->getProcessedReport()
$9/core/API/Proxy.php(244)

$extraProcessedMetrics[] = new VisitsPercent($visitsSum);


  • plugins/Referrers/VisitorDetails.php(99)

Deprecated - urldecode(): Passing null to parameter #1 ($string) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/Referrers/VisitorDetails.php(99)
$2/plugins/Referrers/VisitorDetails.php(22)
$3/plugins/Live/Visitor.php(39)
$4/plugins/Live/API.php(343)
[internal function]: Piwik\Plugins\Live\API->Piwik\Plugins\Live{closure}()
$6/core/DataTable.php(512)
$7/core/DataTable.php(618)
$8/core/API/DataTablePostProcessor.php(303)
$9/core/API/DataTablePostProcessor.php(133)

return urldecode($this->details['referer_name']);


  • plugins/SEO/Metric/Alexa.php(38)

Deprecated - urlencode(): Passing null to parameter #1 ($string) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/SEO/Metric/Alexa.php(38)
$2/plugins/SEO/Metric/Aggregator.php(35)
$3/plugins/SEO/Metric/ProviderCache.php(42)
$4/plugins/SEO/API.php(44)
$5/plugins/SEO/Widgets/GetRank.php(52)
$6/plugins/CoreHome/Controller.php(92)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderWidget()
$8/core/FrontController.php(619)
$9/core/FrontController.php(168)

$response = Http::sendHttpRequest(self::URL . urlencode($domain), $timeout = 10, @$_SERVER['HTTP_USER_AGENT']);


  • plugins/SEO/Metric/Alexa.php(57)

Deprecated - urlencode(): Passing null to parameter #1 ($string) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/SEO/Metric/Alexa.php(57)
$2/plugins/SEO/Metric/Aggregator.php(35)
$3/plugins/SEO/Metric/ProviderCache.php(42)
$4/plugins/SEO/API.php(44)
$5/plugins/SEO/Widgets/GetRank.php(52)
$6/plugins/CoreHome/Controller.php(92)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderWidget()
$8/core/FrontController.php(619)
$9/core/FrontController.php(168)

$link = self::LINK . urlencode($domain);


  • plugins/SEO/Metric/Bing.php(35)

Deprecated - urlencode(): Passing null to parameter #1 ($string) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/SEO/Metric/Bing.php(35)
$2/plugins/SEO/Metric/Aggregator.php(35)
$3/plugins/SEO/Metric/ProviderCache.php(42)
$4/plugins/SEO/API.php(44)
$5/plugins/SEO/Widgets/GetRank.php(52)
$6/plugins/CoreHome/Controller.php(92)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderWidget()
$8/core/FrontController.php(619)
$9/core/FrontController.php(168)

$url = self::URL . urlencode($domain);


  • plugins/SEO/Metric/DomainAge.php(38)

Deprecated - str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/SEO/Metric/DomainAge.php(38)
$2/plugins/SEO/Metric/Aggregator.php(35)
$3/plugins/SEO/Metric/ProviderCache.php(42)
$4/plugins/SEO/API.php(44)
$5/plugins/SEO/Widgets/GetRank.php(52)
$6/plugins/CoreHome/Controller.php(92)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderWidget()
$8/core/FrontController.php(619)
$9/core/FrontController.php(168)

$domain = str_replace('www.', '', $domain);


  • plugins/SEO/Metric/Google.php(49)

Deprecated - urlencode(): Passing null to parameter #1 ($string) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/SEO/Metric/Google.php(49)
$2/plugins/SEO/Metric/Google.php(38)
$3/plugins/SEO/Metric/Aggregator.php(35)
$4/plugins/SEO/Metric/ProviderCache.php(42)
$5/plugins/SEO/API.php(44)
$6/plugins/SEO/Widgets/GetRank.php(52)
$7/plugins/CoreHome/Controller.php(92)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderWidget()
$9/core/FrontController.php(619)

$url = self::SEARCH_URL . urlencode($domain);


  • plugins/SEO/Metric/ProviderCache.php(37)

Deprecated - md5(): Passing null to parameter #1 ($string) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/SEO/Metric/ProviderCache.php(37)
$2/plugins/SEO/API.php(44)
$3/plugins/SEO/Widgets/GetRank.php(52)
$4/plugins/CoreHome/Controller.php(92)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderWidget()
$6/core/FrontController.php(619)
$7/core/FrontController.php(168)
$8/core/dispatch.php(32)
$9/index.php(25)

$cacheId = 'SEO_getRank_' . md5($domain);


  • plugins/MultiSites/API.php(356)

Deprecated - Automatic conversion of false to array is deprecated
$0/plugins/MultiSites/API.php(356)
$1/plugins/MultiSites/API.php(260)
$2/plugins/MultiSites/API.php(103)
[internal function]: Piwik\Plugins\MultiSites\API->getAll()
$4/core/API/Proxy.php(244)
$5/core/Context.php(28)
$6/core/API/Proxy.php(335)
$7/core/API/Request.php(266)
$8/plugins/API/ProcessedReport.php(378)
$9/plugins/API/API.php(287)

$extraProcessedMetrics[] = new $evolutionMetricClass(


  • plugins/VisitsSummary/Reports/Get.php(203)

Deprecated - version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/plugins/VisitsSummary/Reports/Get.php(203)
$2/plugins/VisitsSummary/Reports/Get.php(87)
$3/core/Plugin/ViewDataTable.php(239)
$4/core/ViewDataTable/Factory.php(243)
$5/core/ViewDataTable/Factory.php(156)
$6/core/Plugin/Report.php(318)
$7/plugins/CoreHome/Controller.php(59)
[internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget()
$9/core/FrontController.php(619)

if (version_compare(DbHelper::getInstallVersion(),'4.0.0-b1', '<')) {


  • expects rows of numeric values

Got invalid response from API request: ?module=API&method=CoreAdminHome.archiveReports&idSite=16&period=month&date=2020-09-01&format=json&trigger=archivephp. Response was
DataArray->sumMetricsPivot expects rows of numeric values, non numeric found: '2020-09-14' for column 0 - in plugin Cohorts. #0 /home/lukas/public_html/matomophp8/core/ArchiveProcessor/Loader.php(218): Piwik\ArchiveProcessor\PluginsArchiver->callAggregateAllPlugins(1, 0, false) #1 /home/lukas/public_html/matomophp8/core/ArchiveProcessor/Loader.php(158): Piwik\ArchiveProcessor\Loader->prepareAllPluginsArchive(1, 0) #2 /home/lukas/public_html/matomophp8/core/ArchiveProcessor/Loader.php(101): Piwik\ArchiveProcessor\Loader->prepareArchiveImpl('VisitsSummary') #3 /home/lukas/public_html/matomophp8/core/Context.php(75): Piwik\ArchiveProcessor\Loader->Piwik\ArchiveProcessor\{closure}() #4 /home/lukas/public_html/matomophp8/core/ArchiveProcessor/Loader.php(105): Piwik\Context::changeIdSite(16, Object(Closure)) #5 /home/lukas/public_html/matomophp8/plugins/CoreAdminHome/API.php(278): Piwik\ArchiveProcessor\Loader->prepareArchive('VisitsSummary') #6 /home/lukas/public_html/matomophp8/core/Archive.php(830): Piwik\Plugins\CoreAdminHome\API->archiveReports(16, Object(Piwik\Period\Week), '2020-09-14', '', 'VisitsSummary', '') #7 /home/lukas/public_html/matomophp8/core/Archive.php(629): Piwik\Archive->prepareArchive(Array, Object(Piwik\Site), Object(Piwik\Period\Week)) #8 /home/lukas/public_html/matomophp8/core/Archive.php(576): Piwik\Archive->cacheArchiveIdsAfterLaunching(Array, Array) #9 /home/lukas/public_html/matomophp8/core/Archive.php(502): Piwik\Archive->getArchiveIds(Array) #10 /home/lukas/public_html/matomophp8/core/Archive.php(312): Piwik\Archive->get(Array, 'numeric')
[...]

  • not sure if this one is related to php8.1

Deprecated - Implicit conversion from float 695.5555555555555 to int loses precision
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/vendor/davaxi/sparkline/src/Sparkline/Picture.php(115)
$2/vendor/davaxi/sparkline/src/Sparkline.php(124)
$3/vendor/davaxi/sparkline/src/Sparkline.php(188)
$4/core/Visualization/Sparkline.php(215)
$5/plugins/CoreVisualizations/Visualizations/Sparkline.php(107)
$6/core/Plugin/Controller.php(247)
$7/plugins/UserCountry/Controller.php(142)
[internal function]: Piwik\Plugins\UserCountry\Controller->getLastDistinctCountriesGraph()
$9/core/FrontController.php(619)


Deprecated - Implicit conversion from float 74.08333333332371 to int loses precision
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/vendor/szymach/c-pchart/src/Chart/BaseDraw.php(290)
$2/vendor/szymach/c-pchart/src/Chart/Draw.php(1569)
$3/vendor/szymach/c-pchart/src/Chart/Draw.php(1517)
$4/vendor/szymach/c-pchart/src/Chart/Draw.php(987)
$5/vendor/szymach/c-pchart/src/Chart/Draw.php(115)
$6/vendor/szymach/c-pchart/src/Chart/Draw.php(910)
$7/vendor/szymach/c-pchart/src/Chart/Draw.php(6001)
$8/plugins/ImageGraph/StaticGraph/Evolution.php(27)
$9/plugins/ImageGraph/API.php(496)


Deprecated - imagefilledpolygon(): Using the $num_points parameter is deprecated
[internal function]: Piwik\ErrorHandler::errorHandler()
$1/vendor/szymach/c-pchart/src/Chart/Draw.php(82)
$2/vendor/szymach/c-pchart/src/Chart/Draw.php(910)
$3/vendor/szymach/c-pchart/src/Chart/Draw.php(6001)
$4/plugins/ImageGraph/StaticGraph/Evolution.php(27)
$5/plugins/ImageGraph/API.php(496)
[internal function]: Piwik\Plugins\ImageGraph\API->get()
$7/core/API/Proxy.php(244)
$8/core/Context.php(28)
$9/core/API/Proxy.php(335)


  • vendor/twig/twig/src/Markup.php(38)+(43)
  • fixed in https://github.com/twigphp/Twig/pull/3552 (no release yet)

Deprecated - Return type of Twig\Markup::count() should either be compatible with Countable::count(): int, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
$0/vendor/twig/twig/src/Markup.php(19)
$1/vendor/composer/ClassLoader.php(476)
$2/vendor/composer/ClassLoader.php(344)
$3/tmp/templates_c/7a/7a036532364d2339c82a6df4f07f7846cf6cbdec663dc41aa70fa9438b6cc75a.php(44)
$4/vendor/twig/twig/src/Template.php(394)
$5/vendor/twig/twig/src/Template.php(367)
$6/vendor/twig/twig/src/Template.php(379)
$7/vendor/twig/twig/src/TemplateWrapper.php(40)
$8/vendor/twig/twig/src/Environment.php(277)
$9/core/View.php(318)



Deprecated - Return type of Twig\Node\Node::count() should either be compatible with Countable::count(): int, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
$0/vendor/twig/twig/src/Node/Node.php(23)
$1/vendor/composer/ClassLoader.php(476)
$2/vendor/composer/ClassLoader.php(344)
$3/vendor/twig/twig/src/Node/TextNode.php(22)
$4/vendor/composer/ClassLoader.php(476)
$5/vendor/composer/ClassLoader.php(344)
$6/vendor/twig/twig/src/Parser.php(123)
$7/vendor/twig/twig/src/Parser.php(84)
$8/vendor/twig/twig/src/Environment.php(479)
$9/vendor/twig/twig/src/Environment.php(507)

to be updated...

@Findus23
Copy link
Member Author

Findus23 commented Aug 9, 2021

Some more unsorted warnings:

WARNING [2021-08-09 21:54:51] 266648  /home/lukas/public_html/matomophp8/core/AssetManager/UIAssetCacheBuster.php(49): Deprecated - trim(): Passing null to parameter #1 ($string) of type string is deprecated - Matomo 4.4.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)

Comment by @sgiehl: This one is fixed ✔️

@Findus23 Findus23 added the Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. label Aug 11, 2021
@Findus23
Copy link
Member Author

Findus23 commented Aug 11, 2021

matomo.log gets really large really quickly as there are many deprecation warnings that are called many times per request.

So I wrote a quick script to deduplicate all warnings to make it easier to see them:

logging.py
import re

basepath = "/home/lukas/public_html/matomophp8/"

regex = re.compile(r"\[[\d\w]+\] ([/\w\-\.()]+):(.+) - Matomo 4.4.+ ((?:(?:#0)|(?:\[internal function\])).*)")

warnings = {}

with open("tmp/logs/matomo.log") as f:
    for line in f:
        if not line.startswith("WARNING"):
            continue
        # print(line)
        result = regex.findall(line)
        if not result:
            print(line)
            print(result)
            continue
        path, warning, trace = result[0]
        trace = trace.replace("#","$").split(",")
        warnings[path] = (warning, trace)  # overwrites warnings in the same line

warnings = dict(sorted(warnings.items(), key=lambda item: item[0]))
for path, data in warnings.items():
    warning, trace = data
    path = path.replace(basepath, "").strip()
    print("- [ ]", path)
    print(">", warning.strip())
    for line in trace:
        print(">",line)
    file = path.split("(")[0]
    lineno = path.split("(")[-1][:-1]
    if "vendor" not in file:
        print("> "
              "https://github.com/matomo-org/matomo/"
              "blob/99136cbf3183833b5d9dedb7943873fb8c3a8da5/"
              f"{file}#L{lineno}")
    print()

print(len(warnings), "unique warnings")

I'll add all new warnings I find in the issue above (now also with stack trace as I think some of them are only fixable when knowing where the data comes from).

@tsteur tsteur added this to the 4.5.0 milestone Aug 20, 2021
@justinvelluppillai justinvelluppillai self-assigned this Aug 25, 2021
@justinvelluppillai
Copy link
Contributor

Is it better to make a number of smaller PRs to get these fixes merged or combine them all into one? I've made a few fixes in #17929, there are also many plugin PRs coming.

@tsteur
Copy link
Member

tsteur commented Aug 30, 2021

@justinvelluppillai small ones be a lot better.

@justinvelluppillai justinvelluppillai removed their assignment Sep 7, 2021
@geekdenz geekdenz self-assigned this Sep 13, 2021
geekdenz pushed a commit that referenced this issue Sep 13, 2021
should not break anything and gets rid of a warning
@geekdenz
Copy link
Contributor

Is this too small or a good size?

#17989

I could simply add more commits like this to not make too many PRs.

geekdenz pushed a commit that referenced this issue Sep 13, 2021
@tsteur
Copy link
Member

tsteur commented Sep 13, 2021

It's hard to say re too small or good size @geekdenz . You want to put things that fix the same kind of issue into the same PR. Like if count() is a problem then you put all the places where count is a problem in the same PR. If that then applies to say to more than 10 different files then it may be good to split it in multiple PRs probably simply for the review to be easier but it really depends on a case by case basis.

@geekdenz
Copy link
Contributor

OK. Thanks @tsteur .

I recommend we leave this until at least xdebug works with PHP 8.1.

root@42b8ea256385:/usr/src/myapp# pecl install xdebug
pecl/xdebug requires PHP (version >= 7.2.0, version <= 8.0.99), installed version is 8.1.0RC1
No valid packages found
install failed

I could not login and it seemed to be in a loop which is hard to debug without a debugger.

@geekdenz geekdenz removed their assignment Sep 13, 2021
@geekdenz geekdenz linked a pull request Sep 13, 2021 that will close this issue
11 tasks
@geekdenz
Copy link
Contributor

Basics Work

I gave it another shot without running the VisitorGenerator plugin and basics seem to work now. :-)

image

@Findus23
Copy link
Member Author

My take on "too small" would be to limit the number of PRs, but make a separate commit per fix.

basics seem to work now

I think the basics (as in clicking around in the Matomo UI) already worked before I made any changes. But I might be misremembering something.

@Findus23 Findus23 removed a link to a pull request Sep 13, 2021
11 tasks
@geekdenz
Copy link
Contributor

too small

It's using one's best judgement what is too small or too big i guess.

basics seem to work now

Yeah, just had a quick look at the ui which seems to work. The main problem is probably the tracker.

@geekdenz geekdenz linked a pull request Sep 13, 2021 that will close this issue
11 tasks
@geekdenz geekdenz removed a link to a pull request Sep 13, 2021
11 tasks
@sgiehl
Copy link
Member

sgiehl commented Nov 15, 2021

When running tests locally there occurs a

PHP Deprecated:  Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/matomo/vendor/symfony/console/Symfony/Component/Console/Helper/HelperSet.php on line 104

Which we can't fix without updating symfony console (if it's already fixed there).

--> will be fixed with #18328

@WebWire-NL
Copy link

After fresh installation (with existing database), system check page works well but then after clicking next following error appears in my apache2 error.log
[Sun Nov 28 19:53:17.225769 2021] [php:error] [pid 1729006] [client x.x.x.x:54686] PHP Fatal error: Uncaught DI\Definition\Exception\InvalidDefinition: Entry "Monolog\Logger" cannot be resolved: the class doesn't exist\nFull definition:\nObject (\n class = Monolog\Logger\n lazy = false\n __construct(\n $name = 'piwik'\n $handlers = get(log.handlers)\n $processors = get(log.processors)\n )\n) in /var/www/html/matomo/vendor/php-di/php-di/src/Definition/Exception/InvalidDefinition.php:19\nStack trace:\n#0 /var/www/html/matomo/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(121): DI\Definition\Exception\InvalidDefinition::create()\n#1 /var/www/html/matomo/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(71): DI\Definition\Resolver\ObjectCreator->createInstance()\n#2 /var/www/html/matomo/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(71): DI\Definition\Resolver\ObjectCreator->resolve()\n#3 /var/www/html/matomo/vendor/php-di/php-di/src/Container.php(390): DI\Definition\Resolver\ResolverDispatcher->resolve()\n#4 /var/www/html/matomo/vendor/php-di/php-di/src/Container.php(139): DI\Container->resolveDefinition()\n#5 /var/www/html/matomo/vendor/php-di/php-di/src/Definition/Reference.php(53): DI\Container->get()\n#6 /var/www/html/matomo/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(66): DI\Definition\Reference->resolve()\n#7 /var/www/html/matomo/vendor/php-di/php-di/src/Container.php(390): DI\Definition\Resolver\ResolverDispatcher->resolve()\n#8 /var/www/html/matomo/vendor/php-di/php-di/src/Container.php(139): DI\Container->resolveDefinition()\n#9 /var/www/html/matomo/core/Container/StaticContainer.php(81): DI\Container->get()\n#10 /var/www/html/matomo/core/FrontController.php(269): Piwik\Container\StaticContainer::get()\n#11 [internal function]: Piwik\FrontController::triggerSafeModeWhenError()\n#12 {main}\n thrown in /var/www/html/matomo/vendor/php-di/php-di/src/Definition/Exception/InvalidDefinition.php on line 19, referer: https://mywebsite.com/matomo/index.php?module=Login&action=databaseSetup&clientProtocol=https

Installed packages:
ii libapache2-mod-php8.1 8.1.0-1+020211125.10+debian101.gbp177308 amd64 server-side, HTML-embedded scripting language (Apache 2 module)
ii php-common 2:85+020211110.38+debian101.gbp73ad3b all Common files for PHP packages
ii php8.1-cli 8.1.0-1+020211125.10+debian101.gbp177308 amd64 command-line interpreter for the PHP scripting language
ii php8.1-common 8.1.0-1+020211125.10+debian101.gbp177308 amd64 documentation, examples and common module for PHP
ii php8.1-curl 8.1.0-1+020211125.10+debian101.gbp177308 amd64 CURL module for PHP
ii php8.1-gd 8.1.0-1+020211125.10+debian101.gbp177308 amd64 GD module for PHP
ii php8.1-mbstring 8.1.0-1+020211125.10+debian101.gbp177308 amd64 MBSTRING module for PHP
ii php8.1-mysql 8.1.0-1+020211125.10+debian101.gbp177308 amd64 MySQL module for PHP
ii php8.1-opcache 8.1.0-1+020211125.10+debian101.gbp177308 amd64 Zend OpCache module for PHP
ii php8.1-readline 8.1.0-1+020211125.10+debian101.gbp177308 amd64 readline module for PHP
ii php8.1-sqlite3 8.1.0-1+020211125.10+debian101.gbp177308 amd64 SQLite3 module for PHP
ii php8.1-xml 8.1.0-1+020211125.10+debian101.gbp177308 amd64 DOM, SimpleXML, XML, and XSL module for PHP

@sgiehl
Copy link
Member

sgiehl commented Nov 28, 2021

@WebWire-NL Just to be sure: This happens in the installation process after the system check, right? Could you check if a config file was already created and if so which plugins are listed as active within in?

@WebWire-NL
Copy link

WebWire-NL commented Nov 29, 2021

@sgiehl Hi, i'm sorry but i reverted to php7.4 :( i can't check anymore.... but i guess nothing was done as the server responded with a 500 error. The error appears after the system check page... so system check only gives a warning about git because i tried the latest version.... and then if you try to go to the next step a 500 error will occur and this was what i could find in the server logs.

@sgiehl
Copy link
Member

sgiehl commented Nov 29, 2021

@WebWire-NL Which version did you try to install on PHP 8.1? A latest git checkout or a specific release?

@WebWire-NL
Copy link

WebWire-NL commented Nov 29, 2021 via email

@w41l
Copy link

w41l commented Dec 4, 2021

Got WARNING on stripos() (4.6.1)

WARNING Actions[2021-12-04 03:29:57 UTC] [9d278] /var/www/matomo/plugins/Actions/VisitorDetails.php(156): Deprecated - stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated - Matomo 4.6.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) [internal function]: Piwik\ErrorHandler::errorHandler(),#1/plugins/Actions/VisitorDetails.php(156),#2/plugins/Live/Visitor.php(289),#3/plugins/Live/API.php(348),[internal function]: Piwik\Plugins\Live\API->Piwik\Plugins\Live\{closure}(),#5/core/DataTable.php(512),#6/core/DataTable.php(618),#7/core/API/DataTablePostProcessor.php(304),#8/core/API/DataTablePostProcessor.php(134),#9/core/API/ResponseBuilder.php(190)

@heurteph-ei
Copy link

From https://forum.matomo.org/t/container-php-68-deprecated-container-php-73-deprecated/43930
with PHP 8.1:

on page index.php?module=MultiSites&action=index&idSite=1&period=range&date=previous30

WARNING: \libs\HTML\QuickForm2\Container.php(68): Deprecated - Return type of HTML_QuickForm2_ContainerIterator::hasChildren() should either be compatible with RecursiveArrayIterator::hasChildren(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice - Matomo 4.6.1 - 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: MultiSites, Action: index, In CLI mode: false)

WARNING: \libs\HTML\QuickForm2\Container.php(73): Deprecated - Return type of HTML_QuickForm2_ContainerIterator::getChildren() should either be compatible with RecursiveArrayIterator::getChildren(): ?RecursiveArrayIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice - Matomo 4.6.1 - 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: MultiSites, Action: index, In CLI mode: false)

on page: /index.php?module=Installation&action=systemCheckPage&idSite=1&period=range&date=previous30&showtitle=1&random=1227

WARNING: \core\CliMulti\Process.php(290): Deprecated - trim(): Passing null to parameter #1 ($string) of type string is deprecated - Matomo 4.6.1 - 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: Installation, Action: getSystemCheck, In CLI mode: false)

WARNING: \core\CliMulti\Process.php(308): Deprecated - trim(): Passing null to parameter #1 ($string) of type string is deprecated - Matomo 4.6.1 - 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: Installation, Action: getSystemCheck, In CLI mode: false)

WARNING: \core\CliMulti\Process.php(258): Deprecated - trim(): Passing null to parameter #1 ($string) of type string is deprecated - Matomo 4.6.1 - 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: Installation, Action: getSystemCheck, In CLI mode: false)

@heurteph-ei
Copy link

@sgiehl does one of your last updates fix #17686 (comment) ?
(as a new post in the forum also mentions this bug...)

@sgiehl
Copy link
Member

sgiehl commented Jan 18, 2022

@heurteph-ei That should have been fixed here: https://github.com/matomo-org/matomo/pull/18330/files#diff-71a1671fa6d1cb22b6c82a3eeb8f845616ad6e8b916070267ba75025d5f08d48R156

I guess meanwhile most issues should be sorted out. At least those that were reported here or I was able to find when running the tests on PHP 8.1. There might still be some issues in third party libs we are using, but most of them published updates as well.

@thcipriani
Copy link

In PHP8.1 on Debian I'm seeing the same dependency injection explosion mentioned in #17686 (comment)

Is this known? Should I file a separate issue? What additional details do you need?

Details

(double-escaping due to logging setup, sorry)
PHP Fatal error: Uncaught DI\Definition\Exception\InvalidDefinition: Entry "Monolog\Logger" cannot be resolved: the class doesn't exist

AH01071: Got error 'PHP message: PHP Fatal error:
Uncaught DI\\Definition\\Exception\\InvalidDefinition: Entry "Monolog\\Logger" cannot be resolved: the class doesn't exist
Full definition:
Object (
    class = Monolog\\Logger
    lazy = false
    __construct(
        $name = 'piwik'
        $handlers = get(log.handlers)
        $processors = get(log.processors)
    )
) in <path>/vendor/php-di/php-di/src/Definition/Exception/InvalidDefinition.php:19
Stack trace:
#0 <webroot>/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(121): DI\\Definition\\Exception\\InvalidDefinition::create()
#1 <webroot>/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php(71): DI\\Definition\\Resolver\\ObjectCreator->createInstance()
#2 <webroot>/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php(71): DI\\Definition\\Resolver\\ObjectCreator->resolve()
#3 <webroot>/vendor/php-di/...

@sgiehl
Copy link
Member

sgiehl commented Jan 25, 2022

@thcipriani Where exactly did that error occur? After updating an existing instance or when trying to install a new one?

@thcipriani
Copy link

@thcipriani Where exactly did that error occur? After updating an existing instance or when trying to install a new one?

Happened when "updating" an existing install. Debian sid swapped out the php package, so unattended-upgrades helpfully moved my personal site overnight. I grabbed this out the error log.

@sgiehl sgiehl mentioned this issue Feb 21, 2022
11 tasks
@sgiehl
Copy link
Member

sgiehl commented Feb 21, 2022

I'll close this one now. Wasn't able to find any other issues while clicking randomly through the UI or while running tests on PHP 8.1. There for sure might be some issues somewhere that didn't pop up yet, or that are introduced with new code later. But guess it would be good to handle those in new issues, so we are better able to track them down.

@sgiehl sgiehl closed this as completed Feb 21, 2022
@MatomoForumNotifications

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

https://forum.matomo.org/t/matomo-4-8-0-upgrade-warning-for-htmlspecialchars-using-php8-1/45056/3

@heurteph-ei
Copy link

@sgiehl it seems some htmlspecialchars deprecated function is still in use... (see previous message)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. 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