@tsteur opened this Issue on October 17th 2022 Member

Scheduler: Error array_map(): Argument #2 ($array) must be of type array, bool given for task 'Piwik\Plugins\ScheduledReports\API.sendReport_3'

Not sure if there was any change recently? Seeing this error for the first time I believe. The error happened every hour for the same report. In case more information is needed please let me know what I can do to provide more information.

Below is the report definition:

INSERT INTO `report` (`idreport`, `idsite`, `login`, `description`, `idsegment`, `period`, `hour`, `type`, `format`, `reports`, `parameters`, `ts_created`, `ts_last_sent`, `deleted`, `evolution_graph_within_period`, `evolution_graph_period_n`, `period_param`)
    (3, 4, 'test', 'test', 35, 'week', 7, 'email', 'pdf', '[\"DevicesDetection_getType\",\"UsersFlow_getUsersFlowPretty\",\"Actions_getPageUrls\",\"Events_getCategory\",\"Referrers_getReferrerType\",\"MarketingCampaignsReporting_getSourceMedium\",\"Goals_get_idGoal--22\",\"CustomReports_getCustomReport_idCustomReport--45\"]', '{\"displayFormat\":\"3\",\"emailMe\":true,\"evolutionGraph\":false,\"additionalEmails\":[\"foo.bar<a class='mention' href='https://github.com/test'>@test</a>.de\"]}', '2022-02-14 15:14:34', '2022-10-10 07:17:12', 0, 0, 4, 'month');

And here the custom report definition in case it's needed for reproducing it

INSERT INTO `custom_reports` (`idcustomreport`, `idsite`, `revision`, `report_type`, `name`, `description`, `category`, `subcategory`, `dimensions`, `metrics`, `segment_filter`, `created_date`, `updated_date`, `status`)
    (45, 4, 0, 'table', 'Test', '', 'CustomReports_CustomReports', '', '[\"Events.EventAction\"]', '[\"avg_sum_events_totalevents_per_visits\",\"sum_events_totalevents\",\"avg_sum_corehome_visittotaltime_per_visits\",\"nb_visits\"]', 'eventCategory==foo%2520p%25C3%25A5%2520test;eventUrl==https%253A%252F%252Fwww.bar.com%252Ffoo%252F', '2021-10-15 14:40:51', '2021-10-18 12:22:20', 'active');

Goal definition in case it's needed

INSERT INTO `goal` (`idsite`, `idgoal`, `name`, `description`, `match_attribute`, `pattern`, `pattern_type`, `case_sensitive`, `allow_multiple`, `revenue`, `deleted`, `event_value_as_revenue`)
    (4, 22, 'test', '', 'event_category', 'test', 'exact', 0, 0, 0, 0, 0);
@thesakshidiggikar commented on October 18th 2022

Hello! Can you assign me this issue to would like to solve it out

@justinvelluppillai commented on October 25th 2022 Member

hi @thesakshidiggikar perhaps you could discuss the approach you are considering and maybe the area of code you would look to solve it and we can discuss first before assigning the issue?

@tsteur commented on October 31st 2022 Member

This error is still happening and it's still failing to send the report.

@tsteur commented on October 31st 2022 Member

Here is the stack trace. It's an issue in tcpdf:

Error: {"message":"array_map(): Argument #2 ($array) must be of type array, bool given","file":"/vendor\/tecnickcom\/tcpdf\/include\/tcpdf_fonts.php","line":2005,"request_id":"48f88","backtrace":" on /vendor\/tecnickcom\/tcpdf\/include\/tcpdf_fonts.php(2005)\n#0 /vendor\/tecnickcom\/tcpdf\/include\/tcpdf_fonts.php(2005): array_map(Array, false)\n#1 /vendor\/tecnickcom\/tcpdf\/tcpdf.php(5321): TCPDF_FONTS::UTF8StringToArray('LIVE s...', true, Array)\n#2 /vendor\/tecnickcom\/tcpdf\/tcpdf.php(5126): TCPDF->getCellCode(276.99758333333, 10, 'LIVE s...', 0, false, 'C', 0, '', 0, true, 'T', 'M')\n#3 /core\/TCPDF.php(34): TCPDF->Cell(0, 10, 'LIVE s...', 0, false, 'C', 0, '', 0, false, 'T', 'M')\n#4 /vendor\/tecnickcom\/tcpdf\/tcpdf.php(3666): Piwik\TCPDF->Footer()\n#5 /vendor\/tecnickcom\/tcpdf\/tcpdf.php(3212): TCPDF->setFooter()\n#6 /vendor\/tecnickcom\/tcpdf\/tcpdf.php(3194): TCPDF->endPage()\n#7 /core\/TCPDF.php(73): TCPDF->AddPage('')\n#8 /core\/ReportRenderer\/Pdf.php(275): Piwik\TCPDF->AddPage()\n#9 /core\/ReportRenderer\/Pdf.php(323): Piwik\ReportRenderer\Pdf->paintReportHeader()\n#10 [internal function]: Piwik\ReportRenderer\Pdf->renderReport(Array, 3)\n#11 /plugins\/ScheduledReports\/API.php(579): array_walk(Array, Array)\n#12 [internal function]: Piwik\Plugins\ScheduledReports\API->generateReport('3', 'yesterday', 'en', '3', 'day', 'pdf', false)\n#13 /core\/API\/Proxy.php(244): call_user_func_array(Array, Array)\n#14 /core\/Context.php(28): Piwik\API\Proxy->Piwik\API\{closure}()\n#15 /core\/API\/Proxy.php(335): Piwik\Context::executeWithQueryParameters(Array, Object(Closure))\n#16 /core\/API\/Request.php(267): Piwik\API\Proxy->call('\\Piwik\\Plugins\\...', 'generateReport', Array)\n#17 /plugins\/API\/Controller.php(45): Piwik\API\Request->process()\n#18 [internal function]: Piwik\Plugins\API\Controller->index()\n#19 /core\/FrontController.php(631): call_user_func_array(Array, Array)\n#20 /core\/FrontController.php(169): Piwik\FrontController->doDispatch('API', 'index', Array)\n#21 /core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#22 /index.php(25): require_once('/c...')\n#23 {main}","safemode_backtrace":"#0 [internal function]: Piwik\Plugins\Cloud\Controller->safemode(Array)\n#1 \/core\/FrontController.php(631): call_user_func_array(Array, Array)\n#2 \/core\/FrontController.php(169): Piwik\FrontController->doDispatch('Cloud', 'safemode', Array)\n#3 \/core\/FrontController.php(100): Piwik\FrontController->dispatch('CorePluginsAdmi...', 'safemode', Array)\n#4 \/core\/FrontController.php(140): Piwik\FrontController::(Array)\n#5 \/core\/FrontController.php(190): Piwik\FrontController::(Object(TypeError))\n#6 \/core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#7 \/index.php(25): require_once('\/c...')\n#8 {main}"}

@tsteur commented on October 31st 2022 Member

Note that I have the value it's trying to parse there but I couldn't reproduce this locally. There isn't any issue. It's basically the $siteTitle - $reportTitle. No special characters. It's similar to the one below.

LIVE (foo.bar) bar.com (UA-12345-1, 1234567) - Räkerkerkrkrkr

see also https://3v4l.org/0iF1c.

On production renamed the report title but this didn't help. Then renamed the name of the site and it did help and made it render. So there seems to some issue around that.
For some reason, as soon as I add the last 2 brackets then it fails. Without the last two brackets it works. Meaning site title LIVE (foo.bar) bar.com UA-12345-1, 1234567 doesn't cause an issue.

@tsteur commented on November 7th 2022 Member

Happening again many times today

@sgiehl commented on November 9th 2022 Member

@tsteur This might be something that needs to be fixed in the vendor lib. If I shall have a look and create a PR there let me know

@tsteur commented on November 9th 2022 Member

How much work would that be roughly? cc @mattab that may be something good to do if it's quick. We're having basically one weekly scheduled report for a customer where this is happening. If it's not quick to do, we can maybe reach out and get them to change the name of the site.

@sgiehl commented on November 11th 2022 Member

@tsteur The only way I'm kind of able to reproduce that problem, is when passing a non utf8 string to preg_split. Would you mind looking up the database record, if it maybe contains a char that is not utf8 somehow?

@tsteur commented on November 13th 2022 Member

It's basically the same as https://github.com/matomo-org/matomo/issues/19871#issuecomment-1297582255 which I looked up from the DB. I only replaced a few characters there. It didn't seem like it contained non-utf8 characters. Would it help to fetch the data in a certain way maybe to check if it contains non-utf8?

@sgiehl commented on November 21st 2022 Member

@tsteur does it look normal when exporting the dataset directly from the database?
I'd like to be able to reproduce that, before trying to provide any possible fix.

@tsteur commented on November 21st 2022 Member

Replied in chat 👍

@sgiehl commented on November 23rd 2022 Member

Will try to provide a fix upstream for the tcpdf library if possible.

Powered by GitHub Issue Mirror