WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics for WordPress
Bug in application (3 posts)

  1. mrunkel
    Member
    Posted 2 years ago #

    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/

  2. mrunkel
    Member
    Posted 2 years ago #

    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();
    }
  3. Florin Andrei
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic