Title: [Plugin: Google Analytics for WordPress] Bug in application
Last modified: August 20, 2016

---

# [Plugin: Google Analytics for WordPress] Bug in application

 *  [mrunkel](https://wordpress.org/support/users/mrunkel/)
 * (@mrunkel)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-google-analytics-for-wordpress-bug-in-application/)
 * When we push our wordpress site from our staging server to our production server,
   this app causes the site to crash with a PHP error.
 * The error is:
 * PHP Fatal error: Call to a member function set_defaults() on a non-object in /
   Volumes/Code/web/website/wp-content/plugins/google-analytics-for-wordpress/googleanalytics.
   php on line 1517
 * Line 1517 is the $ga_admin->set_defaults(); in the block below.
 *     ```
       $options	= get_option('Yoast_Google_Analytics');
   
       if (!is_array($options)) {
       	$options = get_option('GoogleAnalyticsPP');
       	if (!is_array($options)) {
       	    $ga_admin->set_defaults();
       	} else {
       		delete_option('GoogleAnalyticsPP');
       		if ($options['admintracking']) {
       			$options["ignore_userlevel"] = '8';
       			unset($options['admintracking']);
       		} else {
       			$options["ignore_userlevel"] = '11';
       		}
       		update_option('Yoast_Google_Analytics', $options);
       	}
       } else {
       ```
   
 * The problem is that $ga_admin is undefined at this point. Adding `$ga_admin =
   new GA_admin;` solves that problem but I’m not sure if this was the original 
   author’s intent for this code.
 * My other question is why doesn’t the get_option function return the options that
   are in the table? Is it somehow tied to the baseurl of the site?
 * My current push procedure involves dumping the wordpress database, replacing 
   the URLs with sed and then loading the site on the production server. This seems
   to work for everything but this plugin.
 * Is there a better way to push between a staging and production server?
 * Thanks,
 * Marc Runkel
 * [http://wordpress.org/extend/plugins/google-analytics-for-wordpress/](http://wordpress.org/extend/plugins/google-analytics-for-wordpress/)

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

 *  Thread Starter [mrunkel](https://wordpress.org/support/users/mrunkel/)
 * (@mrunkel)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-google-analytics-for-wordpress-bug-in-application/#post-2526071)
 * uhh, yeah, my fix doesn’t actually solve the problem because GA_Admin isn’t defined
   until you hit the admin page (even the login page).
 * Probably better to wrap the statement on line 1517 with an is_object() if statement.
 *     ```
       if (is_object($ga_admin)) {
           $ga_admin->setDefaults();
       }
       ```
   
 *  [Florin Andrei](https://wordpress.org/support/users/florin-andrei/)
 * (@florin-andrei)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-google-analytics-for-wordpress-bug-in-application/#post-2526084)
 * We have the exact same issue here. On a network install, after activating this
   plugin, the main site was unaffected, but the other site broke.
 * Your second patch seems to fix the problem, or at least what I can see of it.

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

The topic ‘[Plugin: Google Analytics for WordPress] Bug in application’ is closed
to new replies.

 * ![](https://ps.w.org/google-analytics-for-wordpress/assets/icon.svg?rev=2976619)
 * [MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)](https://wordpress.org/plugins/google-analytics-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analytics-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analytics-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analytics-for-wordpress/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Florin Andrei](https://wordpress.org/support/users/florin-andrei/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-google-analytics-for-wordpress-bug-in-application/#post-2526084)
 * Status: not resolved