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

Getting error array_map() must be of type array when trying to send scheduled report #19871

Closed
tsteur opened this issue Oct 17, 2022 · 14 comments
Assignees
Labels
Bug For errors / faults / flaws. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Oct 17, 2022

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`)
VALUES
	(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@test.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`)
VALUES
	(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`)
VALUES
	(4, 22, 'test', '', 'event_category', 'test', 'exact', 0, 0, 0, 0, 0);
@tsteur tsteur added the Bug For errors / faults / flaws. label Oct 17, 2022
@thesakshidiggikar
Copy link

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

@justinvelluppillai
Copy link
Contributor

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
Copy link
Member Author

tsteur commented Oct 31, 2022

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

@tsteur
Copy link
Member Author

tsteur commented Oct 31, 2022

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
Copy link
Member Author

tsteur commented Oct 31, 2022

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
Copy link
Member Author

tsteur commented Nov 7, 2022

Happening again many times today

@sgiehl sgiehl added this to the For Prioritization milestone Nov 9, 2022
@sgiehl
Copy link
Member

sgiehl commented Nov 9, 2022

@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
Copy link
Member Author

tsteur commented Nov 9, 2022

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.

@mattab mattab modified the milestones: For Prioritization, 4.12.5 Nov 9, 2022
@sgiehl
Copy link
Member

sgiehl commented Nov 11, 2022

@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
Copy link
Member Author

tsteur commented Nov 13, 2022

It's basically the same as #19871 (comment) 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
Copy link
Member

sgiehl commented Nov 21, 2022

@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
Copy link
Member Author

tsteur commented Nov 21, 2022

Replied in chat 👍

@sgiehl sgiehl self-assigned this Nov 23, 2022
@sgiehl
Copy link
Member

sgiehl commented Nov 23, 2022

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

@justinvelluppillai justinvelluppillai modified the milestones: 4.12.5, 4.13.2 Nov 28, 2022
@justinvelluppillai justinvelluppillai modified the milestones: 4.13.2, 4.13.1 Dec 8, 2022
@sgiehl
Copy link
Member

sgiehl commented Dec 23, 2022

This should be fixed with the latest release of tcpdf.

@sgiehl sgiehl closed this as completed Dec 23, 2022
@justinvelluppillai justinvelluppillai added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

No branches or pull requests

5 participants