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

Plugin appears to be breaking in settings screen/widgets screen #42

Closed wadehammes closed 7 years ago

wadehammes commented 8 years ago

Environment: Chrome Version 51.0.2704.103 Wordpress Version 4.5.3

Not sure the specifics on this, but I have screenshots. When inputting my Client IDs, the following happens to my GA Popular Posts admin screen:

screen shot 2016-06-25 at 12 42 00 pm copy

...and subsequently because of this the widgets page is broken: screen shot 2016-06-25 at 12 42 12 pm

Deactivating the plugin fixes the widget screen.

Hope this helps! Can provide more details if needed.

benlk commented 8 years ago

Does the server's error log say anything relevant?

wadehammes commented 8 years ago

@benlk here is some output

[Sat Jun 25 12:33:50.728867 2016] [:error] [pid 29497] [client 24.126.82.26:62537] 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
[Sat Jun 25 12:34:22.803199 2016] [:error] [pid 29134] [client 24.126.82.26:62591] PHP Fatal error:  Call to undefined function of_get_option() in /var/www/html/wp-content/plugins/ga-popular-posts/classes/AnalyticsPopularWidget.php on line 172, referer: http://tortoiseandthesnare.com/wp-admin/
[Sat Jun 25 12:34:33.283545 2016] [:error] [pid 29497] [client 24.126.82.26:62595] PHP Fatal error:  Call to undefined function of_get_option() in /var/www/html/wp-content/plugins/ga-popular-posts/classes/AnalyticsPopularWidget.php on line 172, referer: http://tortoiseandthesnare.com/wp-admin/
[Sat Jun 25 12:35:18.035962 2016] [:error] [pid 30171] [client 24.126.82.26:62605] PHP Fatal error:  Call to undefined function of_get_option() in /var/www/html/wp-content/plugins/ga-popular-posts/classes/AnalyticsPopularWidget.php on line 172, referer: http://tortoiseandthesnare.com/wp-admin/plugins.php?plugin_status=all&paged=1&s&w3tc_note=flush_pgcache
[Sat Jun 25 12:36:07.406088 2016] [:error] [pid 30167] [client 24.126.82.26:62625] PHP Fatal error:  Call to undefined function of_get_option() in /var/www/html/wp-content/plugins/ga-popular-posts/classes/AnalyticsPopularWidget.php on line 172, referer: http://tortoiseandthesnare.com/wp-admin/plugins.php?plugin_status=all&paged=1&s
[Sat Jun 25 12:36:11.761194 2016] [:error] [pid 30167] [client 24.126.82.26:62625] PHP Fatal error:  Call to undefined function of_get_option() in /var/www/html/wp-content/plugins/ga-popular-posts/classes/AnalyticsPopularWidget.php on line 172, referer: http://tortoiseandthesnare.com/wp-admin/widgets.php
[Sat Jun 25 12:36:20.361991 2016] [:error] [pid 30167] [client 24.126.82.26:62625] 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, referer: http://tortoiseandthesnare.com/wp-admin/tools.php
[Sat Jun 25 12:41:21.767410 2016] [:error] [pid 30251] [client 24.126.82.26:62846] 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, referer: http://tortoiseandthesnare.com/wp-admin/plugins.php?plugin_status=all&paged=1&s
[Sat Jun 25 12:41:36.032044 2016] [:error] [pid 2831] [client 24.126.82.26:62859] 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, referer: http://tortoiseandthesnare.com/wp-admin/options-general.php?page=analytic-bridge
[Sat Jun 25 12:41:52.172055 2016] [:error] [pid 30173] [client 24.126.82.26:62861] 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, referer: http://tortoiseandthesnare.com/wp-admin/options-general.php?page=analytic-bridge
[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
benlk commented 8 years ago

Call to undefined function of_get_option()

This appears to be because we're using a function included in Largo inside this plugin:

In AnalyticBridgePopularPostWidget::widget() https://github.com/INN/analytic-bridge/blob/7ef6cfd2ae93761279b9132bc53f3669c2f1640d/classes/AnalyticsPopularWidget.php#L49

    $posts_term = of_get_option( 'posts_term_plural', 'Posts' );

In AnalyticBridgePopularPostWidget::form() https://github.com/INN/analytic-bridge/blob/7ef6cfd2ae93761279b9132bc53f3669c2f1640d/classes/AnalyticsPopularWidget.php#L172

    $defaults = array(
        'title' => __('Recent ' . of_get_option( 'posts_term_plural', 'Posts' ), 'largo'),
        'num_posts' => 3,
        'olul' => 'ol',
        'thumbnail_display' => 'medium',
    );

That's why the widgets page is failing.


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.

I'm going to split this ticket up into a couple of other tickets, for each of those issues.

wadehammes commented 8 years ago

@benlk thanks for looking into this, really excited about this plugin (was going to attempt to build something like it myself if I couldnt find anything!)

benlk commented 8 years ago

Thanks for the bug report! We'll try to get these fixed as soon as possible.

wadehammes commented 8 years ago

@benlk widget screen now works with latest update, still getting the $user error though.

benlk commented 8 years ago

We're still investigating that problem. If you come across any solutions (using a different set of credentials or different format of credentials, maybe?), please do let us know.

benlk commented 8 years ago

Thanks for your patience, and your bug reports!

wadehammes commented 8 years ago

@benlk let me play around with it.

I set up the Google API console with the email I am trying to authenticate with, so not sure why it's not returning a user.

wadehammes commented 8 years ago

Same email also runs my Analytics page.

benlk commented 8 years ago

That's interesting. @jackbrighton have you experienced a similar error when working on #41?

jackbrighton commented 8 years ago

On the site where I was installing and testing GA Popular Posts, while revising the docs, the plugin is broken in a different way. The widgets screen is fine, and the GA Popular Posts widget is available. The Settings > GA Popular Posts screen looks like this:

ga-pop-posts-settings

wadehammes commented 8 years ago

Any progress on this?

benlk commented 7 years ago

@wadehammes, sorry, no, there hasn't been any progress on this. If you're still having this problem, can you send us a copy of your server logs?

benlk commented 7 years ago

Closing for now because this looks similar to a lot of bugs that were fixed in v0.1.2.

wadehammes commented 7 years ago

@benlk thanks!