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

Uncaught exception when sending or downloading scheduled reports #18499

Closed
Starker3 opened this issue Dec 14, 2021 · 12 comments
Closed

Uncaught exception when sending or downloading scheduled reports #18499

Starker3 opened this issue Dec 14, 2021 · 12 comments
Assignees
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Milestone

Comments

@Starker3
Copy link
Contributor

Refs L3-194
We have a user with 4 different Matomo servers, only one of them has this issue.

They are able to get the reports downloaded or sent when using just a "Day" period, but any other period such as week or month results in the above error.

So for example the following scheduled reports fail:

/index.php?module=API&action=index&idSite=10&period=week&date=2021-11-10&limit=100&updated=7&method=ScheduledReports.generateReport&idReport=3&outputType=3&language=en

/index.php?module=API&action=index&idSite=10&period=month&date=2021-11-18&limit=100&updated=8&method=ScheduledReports.generateReport&idReport=3&outputType=3&language=en

And the following one does work:

/index.php?module=API&action=index&idSite=10&period=day&date=2021-12-03&limit=100&updated=9&method=ScheduledReports.generateReport&idReport=3&outputType=3&language=en

Full error output:



ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #18 {main}
-- | -- | -- | -- | --
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #17 /var/www/html/matomo/index.php(25): require_once('...')
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #16 /var/www/html/matomo/core/dispatch.php(32): Piwik\FrontController->dispatch()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #15 /var/www/html/matomo/core/FrontController.php(168): Piwik\FrontController->doDispatch()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #14 /var/www/html/matomo/core/FrontController.php(619): call_user_func_array()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #13 [internal function]: Piwik\Plugins\API\Controller->index()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #12 /var/www/html/matomo/plugins/API/Controller.php(46): Piwik\API\Request->process()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #11 /var/www/html/matomo/core/API/Request.php(266): Piwik\API\Proxy->call()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #10 /var/www/html/matomo/core/API/Proxy.php(335): Piwik\Context::executeWithQueryParameters()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #9 /var/www/html/matomo/core/Context.php(28): Piwik\API\Proxy->Piwik\API\{closure}()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #8 /var/www/html/matomo/core/API/Proxy.php(244): call_user_func_array()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #7 [internal function]: Piwik\Plugins\ScheduledReports\API->generateReport()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #6 /var/www/html/matomo/plugins/ScheduledReports/API.php(540): array_walk()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #5 [internal function]: Piwik\ReportRenderer\Pdf->renderReport()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #4 /var/www/html/matomo/core/ReportRenderer/Pdf.php(333): Piwik\ReportRenderer\Pdf->paintReportTable()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #3 /var/www/html/matomo/core/ReportRenderer/Pdf.php(380): TCPDF->Cell()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #2 /var/www/html/matomo/vendor/tecnickcom/tcpdf/tcpdf.php(5114): TCPDF->getCellCode()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #1 /var/www/html/matomo/vendor/tecnickcom/tcpdf/tcpdf.php(5308): TCPDF_FONTS::UTF8StringToArray()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | #0 /var/www/html/matomo/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php(2004): array_map()
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | Stack trace:
ERROR | Piwik\FrontController | 2021-12-10 11:14:04 UTC | e9fa0 | Uncaught  exception: TypeError: array_map(): Argument #2 ($array) must be of type  array, bool given in  /var/www/html/matomo/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php:2004

Your Environment

  • Matomo Version: 4.5.0
  • PHP Version: 8.0.13
  • Server Operating System: Oracle Linux 8 UEK Release 6 (Kernel 5.4.17)
@Starker3 Starker3 added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Dec 14, 2021
@sgiehl
Copy link
Member

sgiehl commented Dec 14, 2021

@Starker3 Do you know if the data that would be included in the report might contain some special unicode characters, like emojis or similar?

@Starker3
Copy link
Contributor Author

I'll check with the user @sgiehl

@vonloxley
Copy link

We have the same error when generating PDF-Reports, and only then:

ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] Uncaught exception: TypeError: array_map(): Argument #2 ($array) must be of type array, bool given in /var/www/html/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php:2004
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] Stack trace:
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #0 /var/www/html/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php(2004): array_map(Array, false)
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #1 /var/www/html/vendor/tecnickcom/tcpdf/tcpdf.php(5308): TCPDF_FONTS::UTF8StringToArray('Handlungsleitfa...', true, Array)
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #2 /var/www/html/vendor/tecnickcom/tcpdf/tcpdf.php(5114): TCPDF->getCellCode(100, 6, 'Handlungsleitfa...', 'LR', 0, 'L', true, false, 0, true, 'T', 'M')
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #3 /var/www/html/core/ReportRenderer/Pdf.php(380): TCPDF->Cell(100, 6, 'Handlungsleitfa...', 'LR', 0, 'L', true, false)
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #4 /var/www/html/core/ReportRenderer/Pdf.php(333): Piwik\ReportRenderer\Pdf->paintReportTable()
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #5 [internal function]: Piwik\ReportRenderer\Pdf->renderReport(Array, 20)
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #6 /var/www/html/plugins/ScheduledReports/API.php(540): array_walk(Array, Array)
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #7 [internal function]: Piwik\Plugins\ScheduledReports\API->generateReport('5', 'today', 'de', '3', 'day', 'pdf', false)
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #8 /var/www/html/core/API/Proxy.php(244): call_user_func_array(Array, Array)
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC] [93925] #9 /var/www/html/core/Context.php(28): Piwik\API\Proxy->Piwik\API\{closure}()
ERROR Piwik\FrontController[2022-01-10 07:05:28 UTC]

We are using the official docker-image (Apache) version 4.6.2. It is quite likely that unicode charachters are involved. The string in question is most likely Handlungsleitfaden_Umgang mit Corona-Verdachtsfällen.

If you need any more information, please do not hesitate to ask.

@vonloxley
Copy link

This might be related to tecnickcom/TCPDF#464.

@tsteur
Copy link
Member

tsteur commented Jan 10, 2022

We have the same issue in production. Below stack trace:

I see there is a UTF8StringToArray('MyTest dispon...', . I find 3 related action names in the log_action table, they contain below characters, not sure if this causes an issue?

  • Test-Matomo
  •  - Test - 
  • Test d'aMatomo -

ERROR [2022-01-10 22:07:36] 15766 Uncaught exception: TypeError: array_map(): Argument #2 ($array) must be of type array, bool given in vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php:2004
Stack trace:
#0 vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php(2004): array_map(Array, false)
#1 vendor/tecnickcom/tcpdf/tcpdf.php(5308): TCPDF_FONTS::UTF8StringToArray('MyTest dispon...', true, Array)
#2 vendor/tecnickcom/tcpdf/tcpdf.php(5114): TCPDF->getCellCode(100, 6, 'Services dispon...', 'LR', 0, 'L', true, false, 0, true, 'T', 'M')
#3 core/ReportRenderer/Pdf.php(380): TCPDF->Cell(100, 6, 'Services dispon...', 'LR', 0, 'L', true, false)
#4 core/ReportRenderer/Pdf.php(333): Piwik\ReportRenderer\Pdf->paintReportTable()
#5 [internal function]: Piwik\ReportRenderer\Pdf->renderReport(Array, 5)
#6 plugins/ScheduledReports/API.php(540): array_walk(Array, Array)
#7 plugins/ScheduledReports/API.php(608): Piwik\Plugins\ScheduledReports\API->generateReport('5', '2022-01-03', 'fr', 2, 'week')
#8 core/Context.php(75): Piwik\Plugins\ScheduledReports\API->Piwik\Plugins\ScheduledReports{closure}()
#9 plugins/ScheduledReports/API.php(679): Piwik\Context::changeIdSite('5', Object(Closure))
#10 [internal function]: Piwik\Plugins\ScheduledReports\API->sendReport('5')
#11 core/Scheduler/Scheduler.php(276): call_user_func(Array, '5')
#12 core/Scheduler/Scheduler.php(148): Piwik\Scheduler\Scheduler->executeTask(Object(Piwik\Scheduler\Task))
#13 plugins/CoreAdminHome/API.php(69): Piwik\Scheduler\Scheduler->run()
#14 core/CronArchive.php(627): Piwik\Plugins\CoreAdminHome\API->runScheduledTasks()
#15 core/CronArchive.php(264): Piwik\CronArchive->runScheduledTasks()
#16 core/Access.php(661): Piwik\CronArchive->Piwik{closure}()
#17 core/CronArchive.php(269): Piwik\Access::doAsSuperUser(Object(Closure))
#18 plugins/CoreConsole/Commands/CoreArchiver.php(32): Piwik\CronArchive->main()
#19 vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Piwik\Plugins\CoreConsole\Commands\CoreArchiver->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Piwik\Plugins\CoreConsole\Commands\CoreArchiver), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 [internal function]: Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 core/Console.php(130): call_user_func(Array, Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 core/Access.php(670): Piwik\Console->Piwik{closure}()
#25 core/Console.php(131): Piwik\Access::doAsSuperUser(Object(Closure))
#26 core/Console.php(82): Piwik\Console->doRunImpl(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 vendor/symfony/console/Symfony/Component/Console/Application.php(126): Piwik\Console->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 console(32): Symfony\Component\Console\Application->run()
#29 {main}

@tsteur tsteur added this to the 4.7.0 milestone Jan 10, 2022
@tsteur tsteur added the Regression Indicates a feature used to work in a certain way but it no longer does even though it should. label Jan 10, 2022
@Starker3
Copy link
Contributor Author

FYI - Never got confirmation from the end-user if they had special unicode characters (Eg. Emoji, etc)

@peterhashair
Copy link
Contributor

peterhashair commented Jan 12, 2022

@tsteur just confirm the version number for TCPDF and PHP, they fix some issue, I think our issue is related to TCPDF_STATIC::pregSplit https://github.com/tecnickcom/TCPDF/blob/42cd0f9786af7e5db4fcedaa66f717b0d0032320/CHANGELOG.TXT#L20-L22

@tsteur
Copy link
Member

tsteur commented Jan 13, 2022

We're using the latest Matomo 4.6.2 and PHP 8. Not sure what version of TCPDF was included in 4.6.2 @peterhashair

@justinvelluppillai justinvelluppillai modified the milestones: 4.7.0, 4.8.0 Jan 18, 2022
@sgiehl
Copy link
Member

sgiehl commented Jan 18, 2022

@peterhashair @tsteur As mentioned above, this is most likely related to tecnickcom/TCPDF#464
Unless that gets fixed in TCPDF, I'm not sure if there is much we can do about that.

@tsteur
Copy link
Member

tsteur commented Jan 18, 2022

@sgiehl can we fork this repository and apply the fix or so? We have emails failing every day about this for few accounts meaning it's quite a big issue that scheduled reports aren't working

@sgiehl
Copy link
Member

sgiehl commented Jan 18, 2022

There is not yet a fix for that. But I can try to reproduce that locally tomorrow and see if I'm able to provide one. I guess simply suppressing the error might result in some missing text in the PDF. Also I wonder how that error actually occurs. It might mean that regex doesn't support unicode on that system maybe, or that the string contains a character that isn't valid unicode...

@sgiehl sgiehl self-assigned this Jan 19, 2022
@sgiehl
Copy link
Member

sgiehl commented Jan 20, 2022

Turns our this was actually unrelated to TCPDF. Will propose a fix for that soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

No branches or pull requests

6 participants