• Hi Jeff,

    it seems that since the refactoring in version 20180303, GA Google Analytics plugin triggers fatal error in WP-CLI context:

    PHP Fatal error:  Uncaught Error: Call to a member function default_options() on null in /var/www/grossglockner/wordpress/wp-content/plugins/ga-google-analytics/inc/plugin-core.php:171
    

    I think the problem is that WP-CLI does not execute plugin files in global context, so the following line (450 in ga-google-analytics.php) does not actually set a global variable:

    $GA_Google_Analytics = new GA_Google_Analytics();
    

    The error is gone as soon as I change the line to:

    $GLOBALS['GA_Google_Analytics'] = $GA_Google_Analytics = new GA_Google_Analytics();
    

    I don’t know if you use WP-CLI, but would be cool if you could check this problem out ?? To trigger the error, you can try the following WP-CLI command that just lists all installed plugins: wp plugin list

    Cheers,
    ?eslav

    • This topic was modified 6 years, 9 months ago by ?eslav Przywara. Reason: Typo
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Thanks for reporting ?eslav, will add the global variable for the next plugin update. Cheers ??

    Plugin Author Jeff Starr

    (@specialk)

    Just to follow up with this, this change is implemented in the next version (20180816) of GA Google Analytics. Should be available later today or tomorrow.

    Thread Starter ?eslav Przywara

    (@chesio)

    Hi Jeff,

    Thanks a lot! I’m happy to confirm that the problem is gone in version 20180816 ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Fatal error in WP-CLI’ is closed to new replies.