Support » Plugin: Google Analytics for WordPress by MonsterInsights » [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)) {
    	} else {
    		if ($options['admintracking']) {
    			$options["ignore_userlevel"] = '8';
    		} 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?


    Marc Runkel

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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)) {

    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.