@mattab opened this Issue on February 11th 2021 Member

we saw the error below a few times on only 2 customers:

Argument 4 passed to Piwik\Plugins\API\Filter\DataComparisonFilter\ComparisonRowGenerator::compareTable() must be an instance of Piwik\DataTable or null, bool given, called in \/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter\/ComparisonRowGenerator.php on line 205

Expected Behavior

No error

Current Behavior

Error: {"message":"Argument 4 passed to Piwik\Plugins\API\Filter\DataComparisonFilter\ComparisonRowGenerator::compareTable() must be an instance of Piwik\DataTable or null, bool given, called in \/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter\/ComparisonRowGenerator.php on line 205","file":"\/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter\/ComparisonRowGenerator.php","line":94,"request_id":"de03e","backtrace":" on \/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter\/ComparisonRowGenerator.php(94)\n#0 \/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter\/ComparisonRowGenerator.php(205): Piwik\Plugins\API\Filter\DataComparisonFilter\ComparisonRowGenerator->compareTable(Array, Object(Piwik\DataTable), Object(Piwik\DataTable), false)\n#1 \/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter\/ComparisonRowGenerator.php(111): Piwik\Plugins\API\Filter\DataComparisonFilter\ComparisonRowGenerator->compareRow(Object(Piwik\DataTable), Array, Object(Piwik\DataTable\Row), Object(Piwik\DataTable\Row), Object(Piwik\DataTable))\n#2 \/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter\/ComparisonRowGenerator.php(46): Piwik\Plugins\API\Filter\DataComparisonFilter\ComparisonRowGenerator->compareTable(Array, Object(Piwik\DataTable), Object(Piwik\DataTable), Object(Piwik\DataTable))\n#3 \/var\/www\/html\/plugins\/API\/Filter\/DataComparisonFilter.php(224): Piwik\Plugins\API\Filter\DataComparisonFilter\ComparisonRowGenerator->compareTables(Array, Object(Piwik\DataTable), Object(Piwik\DataTable))\n#4 \/var\/www\/html\/core\/API\/DataTablePostProcessor.php(489): Piwik\Plugins\API\Filter\DataComparisonFilter->compare(Object(Piwik\DataTable))\n#5 \/var\/www\/html\/core\/API\/DataTablePostProcessor.php(123): Piwik\API\DataTablePostProcessor->applyComparison(Object(Piwik\DataTable))\n#6 \/var\/www\/html\/core\/Plugin\/Visualization.php(536): Piwik\API\DataTablePostProcessor->process(Object(Piwik\DataTable))\n#7 \/var\/www\/html\/core\/Plugin\/Visualization.php(193): Piwik\Plugin\Visualization->applyFilters()\n#8 \/var\/www\/html\/core\/Plugin\/Report.php(320): Piwik\Plugin\Visualization->render()\n#9 \/var\/www\/html\/plugins\/CoreHome\/Controller.php(58): Piwik\Plugin\Report->render()\n#10 [internal function]: Piwik\Plugins\CoreHome\Controller->renderReportWidget(Object(Piwik\Plugins\Actions\Reports\GetPageUrls))\n#11 \/var\/www\/html\/core\/FrontController.php(605): call_user_func_array(Array, Array)\n#12 \/var\/www\/html\/core\/FrontController.php(166): Piwik\FrontController->doDispatch('Actions', 'getPageUrls', Array)\n#13 \/var\/www\/html\/core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#14 \/var\/www\/html\/index.php(25): require_once('\/var\/www\/html\/c...')\n#15 {main}"}

Possible Solution

Steps to Reproduce (for Bugs)

This was a URL where this happened:
/index.php?segment=abtesting_variation%3D%3Dcb13-v0_Original&date=2020-12-14,2021-02-01&viewDataTable=table&module=Actions&action=getPageUrls&idSite=1&period=range&compareSegments%5B%5D=abtesting_variation%3D%3Dnxxx&random=9155&filter_offset=0&totals=1&search_recursive=1&filter_limit=50&filter_sort_column=nb_visits&filter_sort_order=desc&keep_totals_row=1&enable_filter_excludelowpop=0&flat=0&filter_column_recursive=label&filter_pattern_recursive=xxx

there might be more other urls (we can look in alerts mailbox)

Context

using comparison feature, but not sure what else

@sgiehl commented on February 12th 2021 Member

Guess something like that would prevent the error, but not sure if anything else would need to be changed so it wouldn't occur in the first place.

diff --git a/plugins/API/Filter/DataComparisonFilter/ComparisonRowGenerator.php b/plugins/API/Filter/DataComparisonFilter/ComparisonRowGenerator.php
index 9d97cf8e69..7d77c1ce09 100644
--- a/plugins/API/Filter/DataComparisonFilter/ComparisonRowGenerator.php
+++ b/plugins/API/Filter/DataComparisonFilter/ComparisonRowGenerator.php
@@ -199,10 +199,11 @@ class ComparisonRowGenerator

         // recurse on subtable if there
         $subtable = $row->getSubtable();
+        $compareSubTable = $compareRow ? $compareRow->getSubtable() : null;
         if ($subtable
-            && $compareRow
+            && $compareSubTable
         ) {
-            $this->compareTable($compareMetadata, $subtable, $rootTable, $compareRow->getSubtable());
+            $this->compareTable($compareMetadata, $subtable, $rootTable, $compareSubTable);
         }
     }
@diosmosis commented on February 14th 2021 Member

@sgiehl that looks like the right fix to me

This Issue was closed on February 15th 2021
Powered by GitHub Issue Mirror