@sgiehl opened this Issue on March 22nd 2021 Member

Expected Behavior

Opening a row evolution for a subtable should always work correctly.

Current Behavior

Sometimes when opening a row evolution for a subtable Matomo seems to choose the incorrect datatable to open the row evolution for and tries to open it with an incorrect action (and subtable id), which results in an error.

Steps to Reproduce (for Bugs)

  1. Go to demo.matomo.cloud
  2. Choose Campaign reports
  3. Open a subtable report for one row in the campaign name report
  4. Open a row evolution for one of the subtable records (-->should work)
  5. Open a row evolution for one of the base table records (--> should work)
  6. Open a row evolution for a subtable record again (--> might fail)

See this record:

https://user-images.githubusercontent.com/1579355/112020029-507d1d80-8b30-11eb-9e84-01ac3161758e.mp4

Locally this results in

Call to undefined method Piwik\DataTable\Map::getRowFromLabel() in /srv/matomo/plugins/MarketingCampaignsReporting/API.php line 82

The failing request tries to open a row evolution with a popover parameter like RowAction$3ARowEvolution$3AMarketingCampaignsReporting.getKeywordContentFromNameId$3A$257B$2522idSubtable$2522$253A$25222$2522$257D$3Aemail-jan2019$20$3E$20$40text, which is obviously incorrect, as the action of the parent table should be used. Correct would be RowAction$3ARowEvolution$3AMarketingCampaignsReporting.getName$3A$257B$2522flat$2522$253A0$257D$3Aemail-jan2019 for this case.

Context

This issue might be the real cause for https://github.com/matomo-org/plugin-MarketingCampaignsReporting/issues/61 and maybe some other errors occurring in relation to row evolution

@diosmosis commented on March 22nd 2021 Member

happened on the first try for me

@sgiehl commented on March 22nd 2021 Member

it's seems to be kind of randomly. I guess the javascript uses the "wrong" instance to trigger the evolution, or at least the instance that is used is linked to the wrong datatable or something like that.

@diosmosis commented on March 22nd 2021 Member

@sgiehl found that this bug has something to do w/ this code working incorrectly: https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/CoreHome/javascripts/dataTable_rowactions.js#L167-L171

When we click the row evolution icon, it will trigger that code on the row action instance for the subtable row. The code notices it's in a subtable, and triggers the action for the main row, but with parameters that correctly compute the label for the subtable row.

Up to this point, this.dataTable (for the row action) points to the subtable's instance. When the event is triggered again, it goes to https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/CoreHome/javascripts/dataTable_rowactions.js#L147. When everything is working correctly, that self.dataTable will be the parent table instance (where self.dataTable.params.method = 'MarketingCampaignReporting.getName'). When it fails, that instance will be the subtable instance (where self.dataTable.params.method = 'MarketingCampaignReporting.getKeywordFromNameId').

I'm not sure why those lines fail, I'm guessing the trigger call works on the wrong row instance. It's possible the rowactions are being created strangely or more than once, but I can't find evidence of that.

This Issue was closed on March 23rd 2021
Powered by GitHub Issue Mirror