INN / Google-Analytics-Popular-Posts

A WordPress plugin that uses Google Analytics data to determine the most popular posts on your site and display a list of popular posts via the included widget.
https://wordpress.org/plugins/ga-popular-posts/
23 stars 7 forks source link

If Google_Service_Oauth2($client) doesn't return a user object, the settings page breaks. #44

Closed benlk closed 8 years ago

benlk commented 8 years ago

From #42:

[Sat Jun 25 12:41:58.296835 2016] [:error] [pid 30167] [client 24.126.82.26:62865] PHP Fatal error:  Call to a member function getName() on a non-object in /var/www/html/wp-content/plugins/ga-popular-posts/inc/analytic-bridge-blog-options.php on line 365

In that file,

        $client = analytic_bridge_google_client();
        $client = analytic_bridge_google_client();
        $service = new Google_Service_Oauth2($client);
        $user = $service->userinfo->get();
        ?>

        <div class="google-chip">
            <?php if( !empty($user->picture) ) : ?>
            <span class="google-user-image">
                <img src="<?php echo $user->picture ?>" />
            </span>
            <?php endif; ?>
            <span class="google-user-name">
                <?php echo "Authenticated as " . $user->getName(); ?>
            </span>
        </div>

So the $user being returned isn't a user for some reason, which causes this problem: screen shot 2016-06-25 at 12 42 00 pm copy

benlk commented 8 years ago

I'm curious what the values of $user and $service are.