Title: PHP Fatal error in WP-CLI
Last modified: May 22, 2018

---

# PHP Fatal error in WP-CLI

 *  Resolved [Česlav Przywara](https://wordpress.org/support/users/chesio/)
 * (@chesio)
 * [8 years ago](https://wordpress.org/support/topic/php-fatal-error-in-wp-cli/)
 * Hi Jeff,
 * it seems that since the refactoring in version `20180303`, GA Google Analytics
   plugin triggers fatal error in [WP-CLI](https://wp-cli.org/) 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 8 years ago by [Česlav Przywara](https://wordpress.org/support/users/chesio/).
      Reason: Typo

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [8 years ago](https://wordpress.org/support/topic/php-fatal-error-in-wp-cli/#post-10309338)
 * Thanks for reporting Česlav, will add the global variable for the next plugin
   update. Cheers 🙂
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-fatal-error-in-wp-cli/#post-10598293)
 * 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](https://wordpress.org/support/users/chesio/)
 * (@chesio)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/php-fatal-error-in-wp-cli/#post-10606037)
 * 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.

 * ![](https://ps.w.org/ga-google-analytics/assets/icon-256x256.png?rev=2053004)
 * [GA Google Analytics – Connect Google Analytics to WordPress](https://wordpress.org/plugins/ga-google-analytics/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ga-google-analytics/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ga-google-analytics/)
 * [Active Topics](https://wordpress.org/support/plugin/ga-google-analytics/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ga-google-analytics/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ga-google-analytics/reviews/)

## Tags

 * [wp-cli](https://wordpress.org/support/topic-tag/wp-cli/)

 * 3 replies
 * 2 participants
 * Last reply from: [Česlav Przywara](https://wordpress.org/support/users/chesio/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/php-fatal-error-in-wp-cli/#post-10606037)
 * Status: resolved