@@ -131,7 +131,7 @@ class DataComparisonFilter
131131
132132 public function __construct ($ request , Report $ report = null )
133133 {
134- $ this ->request = $ request ;
134+ $ this ->request = new \ Piwik \ Request ( $ request) ;
135135
136136 $ generalConfig = Config::getInstance ()->General ;
137137 $ this ->segmentCompareLimit = (int ) $ generalConfig ['data_comparison_segment_limit ' ];
@@ -173,7 +173,7 @@ public function __construct($request, Report $report = null)
173173 $ this ->comparePeriodIndices [$ period ][$ date ] = $ index ;
174174 }
175175
176- $ this ->invertCompareChangeCompute = Common:: getRequestVar ('invert_compare_change_compute ' , $ default = 0 , $ type = ' int ' , $ request ) == 1 ;
176+ $ this ->invertCompareChangeCompute = $ this -> request -> getIntegerParameter ('invert_compare_change_compute ' , 0 ) = == 1 ;
177177 if ($ this ->invertCompareChangeCompute && count ($ this ->comparePeriods ) != 2 ) {
178178 throw new \Exception ("invert_compare_change_compute=1 can only be used when comparing two periods. " );
179179 }
@@ -200,8 +200,8 @@ public function compare(DataTable\DataTableInterface $table)
200200 return ;
201201 }
202202
203- $ method = Common:: getRequestVar ( ' method ' , $ default = null , $ type = ' string ' , $ this ->request );
204- if ($ method == 'Live ' ) {
203+ $ method = $ this ->request -> getStringParameter ( ' method ' );
204+ if ($ method === 'Live ' ) {
205205 throw new \Exception ("Data comparison is not enabled for the Live API. " );
206206 }
207207
@@ -295,31 +295,31 @@ private function requestReport($method, $paramsToModify)
295295 'disable_queued_filters ' => 1 ,
296296 'format_metrics ' => 0 ,
297297 'label ' => '' ,
298- 'flat ' => Common:: getRequestVar ('flat ' , 0 , ' int ' , $ this -> request ),
299- 'filter_add_columns_when_show_all_columns ' => Common:: getRequestVar ('filter_add_columns_when_show_all_columns ' , '' , ' string ' , $ this -> request ),
300- 'filter_update_columns_when_show_all_goals ' => Common:: getRequestVar ('filter_update_columns_when_show_all_goals ' , '' , ' string ' , $ this -> request ),
301- 'filter_show_goal_columns_process_goals ' => Common:: getRequestVar ('filter_show_goal_columns_process_goals ' , '' , ' string ' , $ this -> request ),
302- 'idGoal ' => Common:: getRequestVar ('idGoal ' , '' , ' string ' , $ this -> request ),
298+ 'flat ' => $ this -> request -> getIntegerParameter ('flat ' , 0 ),
299+ 'filter_add_columns_when_show_all_columns ' => $ this -> request -> getStringParameter ('filter_add_columns_when_show_all_columns ' , '' ),
300+ 'filter_update_columns_when_show_all_goals ' => $ this -> request -> getStringParameter ('filter_update_columns_when_show_all_goals ' , '' ),
301+ 'filter_show_goal_columns_process_goals ' => $ this -> request -> getStringParameter ('filter_show_goal_columns_process_goals ' , '' ),
302+ 'idGoal ' => $ this -> request -> getStringParameter ('idGoal ' , '' ),
303303 ],
304304 $ paramsToModify
305305 );
306306
307- $ params ['keep_totals_row ' ] = Common:: getRequestVar ('keep_totals_row ' , 0 , ' int ' , $ this -> request );
308- $ params ['keep_totals_row_label ' ] = Common:: getRequestVar ('keep_totals_row_label ' , '' , ' string ' , $ this -> request );
307+ $ params ['keep_totals_row ' ] = $ this -> request -> getIntegerParameter ('keep_totals_row ' , 0 );
308+ $ params ['keep_totals_row_label ' ] = $ this -> request -> getStringParameter ('keep_totals_row_label ' , '' );
309309
310310 if (!isset ($ params ['idSite ' ])) {
311- $ params ['idSite ' ] = Common:: getRequestVar ( ' idSite ' , null , ' string ' , $ this ->request );
311+ $ params ['idSite ' ] = $ this ->request -> getStringParameter ( ' idSite ' );
312312 }
313313 if (!isset ($ params ['period ' ])) {
314- $ params ['period ' ] = Common:: getRequestVar ( ' period ' , null , ' string ' , $ this ->request );
314+ $ params ['period ' ] = $ this ->request -> getStringParameter ( ' period ' );
315315 }
316316 if (!isset ($ params ['date ' ])) {
317- $ params ['date ' ] = Common:: getRequestVar ( ' date ' , null , ' string ' , $ this ->request );
317+ $ params ['date ' ] = $ this ->request -> getStringParameter ( ' date ' );
318318 }
319319
320- $ idSubtable = Common:: getRequestVar ('idSubtable ' , 0 , ' int ' , $ this -> request );
320+ $ idSubtable = $ this -> request -> getIntegerParameter ('idSubtable ' , 0 );
321321 if ($ idSubtable > 0 ) {
322- $ comparisonIdSubtables = Common:: getRequestVar ('comparisonIdSubtables ' , $ default = false , ' json ' , $ this -> request );
322+ $ comparisonIdSubtables = $ this -> request -> getJsonParameter ('comparisonIdSubtables ' , false );
323323 if (empty ($ comparisonIdSubtables )) {
324324 throw new \Exception ("Comparing segments/periods with subtables only works when the comparison idSubtables are supplied as well. " );
325325 }
@@ -389,8 +389,10 @@ private function getMetadataFromModifiedParams($modifiedParams)
389389
390390 $ metadata ['compareSegment ' ] = $ segment ;
391391
392- $ segmentObj = new Segment ($ segment , []);
393- $ metadata ['compareSegmentPretty ' ] = $ segmentObj ->getStoredSegmentName (false );
392+ $ idSite = $ modifiedParams ['idSite ' ] ?? $ this ->request ->getStringParameter ('idSite ' );
393+
394+ $ segmentObj = new Segment ($ segment , [$ idSite ]);
395+ $ metadata ['compareSegmentPretty ' ] = $ segmentObj ->getStoredSegmentName ($ idSite );
394396
395397 $ metadata ['comparePeriod ' ] = $ period ;
396398 $ metadata ['compareDate ' ] = $ date ;
@@ -457,8 +459,8 @@ private function checkMultiplePeriodCompare()
457459 private function isRequestMultiplePeriod ()
458460 {
459461 if ($ this ->isRequestMultiplePeriod === null ) {
460- $ period = Common:: getRequestVar ( ' period ' , $ default = null , ' string ' , $ this ->request );
461- $ date = Common:: getRequestVar ( ' date ' , $ default = null , ' string ' , $ this ->request );
462+ $ period = $ this ->request -> getStringParameter ( ' period ' );
463+ $ date = $ this ->request -> getStringParameter ( ' date ' );
462464
463465 $ this ->isRequestMultiplePeriod = Period::isMultiplePeriod ($ date , $ period );
464466 }
@@ -599,7 +601,7 @@ private static function getCompareDates($request = null)
599601 */
600602 private function shouldIncludeTrendValues (): bool
601603 {
602- return ( bool ) Common:: getRequestVar ( 'include_trends ' , 0 , ' int ' , $ this -> request );
604+ return $ this -> request -> getBoolParameter ( 'include_trends ' , false );
603605 }
604606
605607 /**
@@ -615,8 +617,9 @@ public static function getPrettyComparisonLabelFromSeriesIndex($labelSeriesIndex
615617
616618 [$ periodIndex , $ segmentIndex ] = self ::getIndividualComparisonRowIndices (null , $ labelSeriesIndex , count ($ compareSegments ));
617619
618- $ segmentObj = new Segment ($ compareSegments [$ segmentIndex ], []);
619- $ prettySegment = $ segmentObj ->getStoredSegmentName (false );
620+ $ idSite = \Piwik \Request::fromRequest ()->getStringParameter ('idSite ' );
621+ $ segmentObj = new Segment ($ compareSegments [$ segmentIndex ], [$ idSite ]);
622+ $ prettySegment = $ segmentObj ->getStoredSegmentName ($ idSite );
620623
621624 $ prettyPeriod = Factory::build ($ comparePeriods [$ periodIndex ], $ compareDates [$ periodIndex ])->getLocalizedLongString ();
622625 $ prettyPeriod = ucfirst ($ prettyPeriod );
0 commit comments