I think I installed module fine. resolved all dependency. can set all configuration but when I try to refresh i get WSOD. Even cron is failing due to this.

Comments

ajayg’s picture

Here is the error in apache error log
PHP Fatal error: Call to undefined method stdClass::getMetrics() in ../sites/all/modules/mostpopular/modules/mostpopular_ga/mostpopular_ga.module on line 114, referer: http://mydomain.com/admin/settings/mostpopular

fran seva’s picture

I post a patch in #1198958: Most Popular calls Google Analytics API but is now Google Analytics Reports that should fix it.
Move the thread to this issue

Hello,
Attach the patch to resolve the following problems:

* Undefined function getMetrics and getDimensions undefined functions.
* Change the request objetc use in function google_analytics_api_report_data

The request object changes:

$request = array(
-            '#dimensions' => array('pagePath'),
-            '#metrics' => 'pageviews',
-            '#sort_metric' => '-pageviews',
-            '#filter' => 'pagePath != / && pagePath !@ 404.html && pagePath !@ /user && pagePath !@ /admin',
-            '#start_date' => $start_ts,
-            '#end_date' => $end_ts,
+            'dimensions' => array('ga:pagePath'),
+            'metrics' => array('ga:pageviews'),
+            'sort_metric' => array('-ga:pageviews'),
+            'filter' => 'pagePath != / && pagePath !@ 404.html && pagePath !@ /user && pagePath !@ /admin',
+            'start_date' => $start_ts,
+            'end_date' => $end_ts,
           );

The workaround to avoid the undefined functions:

           $status = '';
-          foreach ($data as $v) {
-            $metrics = $v->getMetrics();
-            $dimensions = $v->getDimensions();
+          foreach ($data->results as $v) {
 
-            $count = $metrics['pageviews'];
-            $url = $dimensions['pagePath'];
+            $count = $v['pageviews'];
+            $url = $v['pagePath'];
             $status .= "$url ($count)"; 
fran seva’s picture

Status: Active » Needs review

Change the status to "needs review".

tomasbedrich’s picture

Status: Needs review » Reviewed & tested by the community

Thank you fran seva, it works.

sutharsan’s picture

Code reviewed and it looks fine. Tested and works as advertized. Let's get this thing committed.

sutharsan’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

The patch in this issue is cross posted from #1198958: Most Popular calls Google Analytics API but is now Google Analytics Reports. Closing this issue in favor of the latter.

ajayg’s picture

Status: Closed (duplicate) » Reviewed & tested by the community

I followed all the threads cross linked but no where it is marked as "fixed" which is next step after RTBC. Someone needs to say this is in latest version and mark is fixed atleast in one thread.

Ideally we should mark this fixed in the same thread it is reviewed. Currently this is RTBC is one thread but patch attached in different thread can be more confusing.

sutharsan’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Marking an issue duplicate is an attempt to clean up the issue queue. The patch in this issue originates from #1198958: Most Popular calls Google Analytics API but is now Google Analytics Reports and is marked rtbc there. This issue covers exactly the same problem and has the same solution. Having multiple issue for the same problem won't help getting the patch committed, it only clutters the issue queue.