Skip to content

Fix for stalled blog options on network activation #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 22, 2021

Conversation

ulkoalex
Copy link
Contributor

@ulkoalex ulkoalex commented Aug 8, 2021

  1. When plugin activated on WP network and some blogs have wrong/empty Piwik options (wp-piwik-site_id etc) - it's continuously requesting Matomo server via WP_Piwik::requestPiwikSiteId() trying to update site_id, but blog option saved via self::$settings->setOption ( 'site_id', $siteId ); is overridden then from $this->settings in Settings::save()
    Also, in TrackingCode::__construct() it calls self::$wpPiwik->updateTrackingCode () with empty $siteId and $blogId params
    Suggested fix: use get_current_blog_id() when $blogID is empty and remove else and always store local blog options in $this->settings, maybe limited by condition like
	public function setOption($key, $value, $blogID = null) {
		if (empty( $blogID )) {
			$blogID = get_current_blog_id();
		}
		$this->settingsChanged = true;
		if ($this->checkNetworkActivation ()) {
			update_blog_option ( $blogID, 'wp-piwik-'.$key, $value );
		}
		if ($blogID == get_current_blog_id()) {
			$this->settings [$key] = $value;
		}
	}

to avoid any collisions..
2. Replace add_blog_option() with update_blog_option() to update existing options
3. Same for add_site_option() vs update_site_option() in Settings::prepareTrackingCode()
4. Fix PHPDoc param order

@braekling braekling merged commit 2ee85fd into braekling:master Aug 22, 2021
@braekling
Copy link
Owner

Same here, thanks a lot!

braekling added a commit that referenced this pull request Aug 22, 2021
* Fix feed tracking via proxy script (thanks to nicobilliotte, [details](#92))
* Add piwik.php proxy script wrapper to make sure proxy tracking codes continue working if piwik.php is used
* Fix for stalled blog options on network activation (thanks to ulkoalex, [details](#94))
* Fix wrong title on city statistics (thanks to ulkoalex, [details](#95))
* [Fix "call to undefined method" error on network admin](https://wordpress.org/support/topic/fatal-error-call-to-undefined-method-wp_piwikadminnetworkgetpluginurl/)
* Do not allow to set empty WP-Matomo display name
* Rename Piwik link on dashboard widget to Matomo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants