• I have a wordpress network and noticed a LOT of request to the piwik server to get the javascript code.

    I checked the database options for some of the sites hosted in the network and none of them had the _piwik_ options set only wp-piwik-last_tracking_code_update

    So wp-piwik requested new code over and over again.

    I digged a bit into the code and noticed that add_blog_option did not work got into setOption

    there the add_blog_option returned false, makes sense since the option already exists, changed that on to update_blog_option

    but still no success, seemed that the options where reset some else.

    So I moved the $this->settings [$key] = $value; outside the if/else

    resulting in

    public function setOption($key, $value, $blogID = null) {
                    $this->settingsChanged = true;
                    self::$wpPiwik->log ( 'Changed option ' . $key . ': ' . $value );
                    if ($this->checkNetworkActivation () && ! empty ( $blogID )) {
                            if ( ! update_blog_option ( $blogID, 'wp-piwik-'.$key, $value ) ) {
                                 add_blog_option ( $blogID, 'wp-piwik-'.$key, $value );
                            }
                    }
                            $this->settings [$key] = $value;
            }

    not sure the function was actual the cause but it solved the problem. The database tables are now populated with piwik options.

    https://www.ads-software.com/plugins/wp-piwik/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author braekling

    (@braekling)

    Hm, this is a strange behavior. Can you please try to check the values of $this->checkNetworkActivation and $blogID? Maybe this gives a hint on what’s happening.

    Thanks a lot.

    Thread Starter brbrbr

    (@brbrbr)

    both are set correctly and the ‘update_blog_option’ is caled with the correct parameters. But somehow later on the settings got overwritten by empty ones. That’s where moving $this->settings [$key] = $value; outside the else made the difference

    Plugin Author braekling

    (@braekling)

    Ok… to be honest, currently I have no idea what’s happening there.

    Only the tracking code was affected? All other settings could be stored as expected all the time? I will try to reconstruct this issue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘options not updating’ is closed to new replies.