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

WARNING | Trying to add two strings in DataTable\Row::sumRowArray #76

Open
MichaIng opened this issue Jun 22, 2021 · 11 comments
Open

WARNING | Trying to add two strings in DataTable\Row::sumRowArray #76

MichaIng opened this issue Jun 22, 2021 · 11 comments

Comments

@MichaIng
Copy link
Contributor

Sometimes, every 1-3 days, a random bot access causes large number of such log entries:

WARNING API 2021-06-20 23:20:02 UTC 18606
/var/www/matomo/core/DataTable/Row.php(772): Trying to add two strings in DataTable\Row::sumRowArray: GoogleBot + Google Instant for column botName in row # ['label' => -1, 'botId' => 9, 'idsite' => 2, 'botName' => 'GoogleBot', 'botKeyword' => 'Googlebot', 'botCount' => 5, 'botLastVisit' => '2021-05-20 16:36:44', 'extra_stats' => 1] [] [idsubtable = ]

...

WARNING API 2021-06-20 23:20:02 UTC c3618
/var/www/matomo/core/DataTable/Row.php(772): Trying to add two strings in DataTable\Row::sumRowArray: 0 + 2021-05-24 02:09:13 for column botLastVisit in row # ['label' => -1, 'botId' => 735, 'idsite' => 35, 'botName' => 0, 'botActive' => 35, 'botKeyword' => 0, 'botCount' => 501, 'botLastVisit' => 0, 'extra_stats' => 34] [] [idsubtable = ]

Those are the first and the last of such entries, framing a three-digits number of such logs, like once for each bot and each column/field. As can be seen, somehow two neighbour field values are somehow tried to be added to a single field and another field may hence be empty (botActive in first log). And then values seem to be shifted, to get a 'botId' => 735 and 'idsite' => 35, which both do not exist (also not in the raw database), so even the logging itself seems to mix something up.

First I though it might happen when the BotTracker settings are saved, as then all those database entries are written, but neither could I find an issue in the related code, nor could I replicate it. The log error instead appears independently of settings changes and repeatedly without touching settings.

Most likely it has something to do with PHP8.0 and I'm not sure if the Matomo archive CLI/cron job may be involved, if it includes archiving the current BotTracker data and does something wrong there? The database itself btw looks pretty fine, no errors no suspicious entries. The extended stats table is not affected by this.

@MichaIng MichaIng changed the title Trying to add two strings in DataTable\Row::sumRowArray WARNING | Trying to add two strings in DataTable\Row::sumRowArray Jun 22, 2021
@Thomas--F
Copy link
Owner

I didn't get this warning but it seems to be connected to some reports.
Regarding matomo-org/matomo#4706 and matomo-org/matomo#6485

Did you alter one of the BotTracker-reports, e.g. add columns or change the format/graph?
Can you check if the warning appears when you open one of the reports?

@MichaIng
Copy link
Contributor Author

MichaIng commented Jun 22, 2021

Indeed, changing the reports table to bar graph and back to simple table triggers exactly these errors, but only with CoreHome tag, while as seen above it always was API.

And now I found the trigger for those with API tag: The Matomo Android App, when checking the "Visitors" page. There are three BotTracker graphs expected, but all empty (was always the case). That app uses the ImageGraph plugin, but disabling this, while it breaks all other graphs in the app, the error logs still happen.

Okay, so it's not about tracking bots, but about reading/visualising the report.

@Thomas--F
Copy link
Owner

OK, one step after the other.
Now that you can reproduce the warning I will try to setup a test enviroment and do some debugging. Give me some days, there's already a lot of work on my desk.

@MichaIng
Copy link
Contributor Author

Many thanks. Let me know if I can help or do further tests here. I'll have a look through the related code Matomo-side as well.

@Thomas--F
Copy link
Owner

Sorry, but I cannot reproduce the error.

My test enviroment is:
Matomo-Version: 4.3.1
MySQL-Version: 10.3.29-MariaDB-0+deb10u1
PHP-Version: 8.0.7
BotTracker: 2.03

I have no production-data so I wrote a simple php-page to simulate some bot-hits.
But whatever I change on the BotTracker-Reports (Dashboard or visitor->BotTracker) I see nothing in my logs (apache2 or matomo-log).
Sometimes the report doesn't show anything or useless data, but there is no warning or error.

Can you describe, how I can trigger the warning and where I can see it?

@MichaIng
Copy link
Contributor Author

With this two ways I can trigger the error is:

Via Matomo Android app

  1. Go to Reports > Visitors
  2. Scroll down to the three BotTracker (Visits), BotTracker Display (Visits) and Top 10 Bots (Visits) reports which all show "No data for this graph"

Via Matomo web interface

  1. Go to Visitors > BotTracker
  2. Change BotTracker report visualisation to "Vertical bar graph" or "Pie chart"

The logs of warning severity appear in the Matomo log file, while I usually use the Log Viewer app to see them. When I trigger them freshly, then reload the log viewer on the other browser tab, they are additionally shown as large orange/yellow notice above the actual log viewer content:

bottracker

Interesting on web interface: When only "Visit Count" is selected from within the "Vertical bar graph" view, then changed to the pie chart, it does not trigger the error anymore. But when switching back to "Simple table" and back to "Pie graph", it re-appears.

And now, after switching several times back and forth, suddenly the graphs show only one bot "Others", covering 100% of all visits. It seems to depend on whether the simple table is sorted by visits count or by e.g. bot name or last visit. And the behaviour also changes depending on whether the visualisation is switched from table view to graph or from one graph view to the other.

The "Others 100%" reminds me of this issue: matomo-org/matomo#17615
This commit caused a similar issue with the Insights plugin widgets (not error, but all page titles merged into "Others"), due to a change in how the summary table is handled: matomo-org/matomo@8366ad8

The other thing is that obviously the BotTracker graph views do not switch/handle selected/shown metrics correctly. When switching to bar chart, also last visit, bot name and keyword are selected and get an individual graph (bot name and key word with zero height), instead of having the bot name on the x-axis below the bars. On the pie chart, only one metric is shown, which is bot name by default, which does not make any sense of course. When changing to the only reasonable visits count, the associated bot names are not shown (similar to bar chart), when then switching back to simple table view, only the visits count is in the table and a page reload required to have again all columns. The error is triggered with nearly every change in the visualisation.

The "Top 10 Bots" report btw doesn't have any issue, it shows the visit counts with bot names associated correctly in every visualisation. The widgets suffers from the same issue for me.

Here a screenshot from the bar chart when changing from simple table to it:

bottracker

The two empty check boxes (without label) show the "idsite" and "extra_stats" (strangely both with a number of 33, instead of expected 1, matching the log messages where those got confused as well) on bars and an extra "bot" named "Others" which based on the visit count seems to be the sum of all bots.

To me it looks like this new handling of the summary row plays a role, as this "Others" entry appears here often combined with wrong visualised data.

Just to rule it out, we have quite some plugins disabled:

Plugins Activated Plugins Deactivated
API, Actions, Annotations, BotTracker 2.03, BulkTracking, CoreAdminHome, CoreConsole, CoreHome, CorePluginsAdmin, CoreUpdater, CoreVisualizations, DBStats, DarkTheme 1.1.6, Dashboard, DevicePlugins, DevicesDetection, Diagnostics, Goals, ImageGraph, Insights, Installation, Intl, LanguagesManager, Live, LogViewer 4.0.1, Login, Marketplace, Monolog, Morpheus, PagePerformance, PrivacyManager, Proxy, Referrers, Resolution, SEO, SegmentEditor, SitesManager, Transitions, UserLanguage, UsersManager, VisitFrequency, VisitTime, VisitorInterest, VisitsSummary, WebsiteMeasurable Contents, CustomDimensions, CustomJsTracker, CustomVariables, Ecommerce, Events, Feedback, GeoIp2, Heartbeat, IntranetMeasurable, MobileAppMeasurable, MobileMessaging, MultiSites, Overlay, ProfessionalServices, Provider, RssWidget, ScheduledReports, TagManager, Tour, TwoFactorAuth, UserCountry, UserCountryMap, UserId, Widgetize

@Thomas--F
Copy link
Owner

OK, thanks for the detailed bug report.:thumbsup:

I can now see the warnings. Then appear as soon as I switvh to the extendet table. As long as I use the simple table everything (even the pie graph and the vertival bar graph) looks good.
I don't know what aditional columns matomo tries to collect, but I think I have to configure at least the datatype of the columns, so the chart-plugin will not try to add strings.
I will do some code changes and tests during the week and see, how far I get.

@MichaIng
Copy link
Contributor Author

Many thanks. Let me know if I can be of help, for testing a commit or so.

Thomas--F added a commit that referenced this issue Jul 1, 2021
Thomas--F added a commit that referenced this issue Jul 1, 2021
Thomas--F added a commit that referenced this issue Jul 1, 2021
Thomas--F added a commit that referenced this issue Jul 1, 2021
@Thomas--F
Copy link
Owner

I tried some changes but I didn't find the real problem or how I can tell matomo, which columns are numbers and which are not.
So the only solution was to disable all functions and visualisations, thart cause the warnings.
It's no loss because these functions and visualisations never worked so far.

If you want to test it, download the dev-4,.x-branch oder exchange at least the files:
API.php
Reports/GetBotTracker.php
Reports/GetBotTrackerAnzeige.php
Reports/GetTop10.php

Maybe you have to reset your dashboard after that.

@MichaIng
Copy link
Contributor Author

MichaIng commented Jul 5, 2021

Jep, I agree that the other visualisations don't make much sense anyway and the Top 10 Bots one is there to have it for the top 10 bots at least. I tested the changes and it works well: No option to change visualisation and hence no errors 👍.

But the Matomo Android app still produces the error, trying to create three graphs but ending up with "No data for this graph" as mentioned above. Probably it makes sense to replace those with a single table with bot name and visits count. The other graphs in the app are mostly time series/evolution graphs while BotTracker has a single accumulated visits table only. The app uses the ImageGraph plugin which uses the Metadata API. It allows to produce other Graphs as well, but funnily on the here linked documentation page, the Pie chart is failing as well, so probably there is a bug in the API itself, or an incompatibility between the API the the ImageGraph plugin.

@Thomas--F
Copy link
Owner

I've bee trying for hours now, but I think it's impossible to create a report with 2 columns, that aren't numbers.
You can name the BotName-Column as "label" so it doesn't show up in the bar chart, but I didn't find a solution for the lastVisit-Column. As far as the plugin-API deliveres such a DataTable, the MetadataAPI tries to use all columns of it and runs straight agains a wall.
So the restiction for the website eliminates most of the errors, but I cannot stop the app from trying to corrupt the data it gets.

The next thing I will try is to hide the lastVisit-column in the metadata, but I haven't found a way to add this data to the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants