diff --git a/classes/WpMatomo/Admin/AdvancedSettings.php b/classes/WpMatomo/Admin/AdvancedSettings.php
index 7f9c9e35f..77c9c93d2 100644
--- a/classes/WpMatomo/Admin/AdvancedSettings.php
+++ b/classes/WpMatomo/Admin/AdvancedSettings.php
@@ -9,6 +9,7 @@
namespace WpMatomo\Admin;
+use Piwik\CliMulti\Process;
use Piwik\IP;
use WpMatomo\Bootstrap;
use WpMatomo\Capabilities;
@@ -68,8 +69,10 @@ public function show_settings() {
}
Bootstrap::do_bootstrap();
- $matomo_detected_ip = IP::getIpFromHeader();
- $matomo_delete_all_data = $this->settings->should_delete_all_data_on_uninstall();
+ $matomo_detected_ip = IP::getIpFromHeader();
+ $matomo_delete_all_data = $this->settings->should_delete_all_data_on_uninstall();
+ $matomo_disable_async_archiving = $this->settings->is_async_archiving_disabled_by_option();
+ $matomo_async_archiving_supported = $this->settings->is_async_archiving_supported();
include dirname( __FILE__ ) . '/views/advanced_settings.php';
}
@@ -93,14 +96,16 @@ public function can_user_manage() {
}
private function apply_settings() {
+ $changes = [
+ Settings::DISABLE_ASYNC_ARCHIVING_OPTION_NAME => ! empty( $_POST['matomo']['disable_async_archiving'] ),
+ ];
+
if ( ! defined( 'MATOMO_REMOVE_ALL_DATA' ) ) {
- $this->settings->apply_changes(
- [
- Settings::DELETE_ALL_DATA_ON_UNINSTALL => ! empty( $_POST['matomo']['delete_all_data'] ),
- ]
- );
+ $changes[ Settings::DELETE_ALL_DATA_ON_UNINSTALL ] = ! empty( $_POST['matomo']['delete_all_data'] );
}
+ $this->settings->apply_changes( $changes );
+
$client_headers = [];
if ( ! empty( $_POST[ self::FORM_NAME ]['proxy_client_header'] ) ) {
$client_header = sanitize_text_field( wp_unslash( $_POST[ self::FORM_NAME ]['proxy_client_header'] ) );
diff --git a/classes/WpMatomo/Admin/SystemReport.php b/classes/WpMatomo/Admin/SystemReport.php
index f8276061e..6d89872ad 100644
--- a/classes/WpMatomo/Admin/SystemReport.php
+++ b/classes/WpMatomo/Admin/SystemReport.php
@@ -673,6 +673,12 @@ private function get_matomo_info() {
'comment' => '',
];
+ $rows[] = [
+ 'name' => 'Async Archiving Disabled in Setting',
+ 'value' => $this->settings->is_async_archiving_disabled_by_option(),
+ 'comment' => '',
+ ];
+
$location_provider = LocationProvider::getCurrentProvider();
if ( $location_provider ) {
$rows[] = [
@@ -1069,7 +1075,6 @@ private function get_wordpress_info() {
'WP_CRON_LOCK_TIMEOUT',
'WP_DISABLE_FATAL_ERROR_HANDLER',
'MATOMO_SUPPORT_ASYNC_ARCHIVING',
- 'MATOMO_TRIGGER_BROWSER_ARCHIVING',
'MATOMO_ENABLE_TAG_MANAGER',
'MATOMO_SUPPRESS_DB_ERRORS',
'MATOMO_ENABLE_AUTO_UPGRADE',
diff --git a/classes/WpMatomo/Admin/views/advanced_settings.php b/classes/WpMatomo/Admin/views/advanced_settings.php
index 0be7fc568..e87a52d54 100644
--- a/classes/WpMatomo/Admin/views/advanced_settings.php
+++ b/classes/WpMatomo/Admin/views/advanced_settings.php
@@ -74,6 +74,25 @@
+
+
+
+ |
+
+
+ value="1" name="matomo[disable_async_archiving]"
+ id="matomo[disable_async_archiving]"
+ />
+
+ |
+
+
+ |
+
|
diff --git a/classes/WpMatomo/Settings.php b/classes/WpMatomo/Settings.php
index 0b90f390b..f8da17e57 100644
--- a/classes/WpMatomo/Settings.php
+++ b/classes/WpMatomo/Settings.php
@@ -13,6 +13,7 @@
namespace WpMatomo;
+use Piwik\CliMulti\Process;
use WpMatomo\Admin\CookieConsent;
use WpMatomo\Admin\TrackingSettings;
@@ -33,6 +34,7 @@ class Settings {
const DELETE_ALL_DATA_ON_UNINSTALL = 'delete_all_data_uninstall';
const SITE_CURRENCY = 'site_currency';
const NETWORK_CONFIG_OPTIONS = 'config_options';
+ const DISABLE_ASYNC_ARCHIVING_OPTION_NAME = 'matomo_disable_async_archiving';
public static $is_doing_action_tracking_related = false;
/**
@@ -107,6 +109,7 @@ class Settings {
'force_protocol' => 'disabled',
'maxmind_license_key' => '',
self::SHOW_GET_STARTED_PAGE => 1,
+ self::DISABLE_ASYNC_ARCHIVING_OPTION_NAME => false,
];
/**
@@ -486,4 +489,12 @@ public function track_search_enabled() {
public function set_assume_is_network_enabled_in_tests( $network_enabled = true ) {
$this->assume_is_network_enabled_in_tests = $network_enabled;
}
+
+ public function is_async_archiving_supported() {
+ return Process::isSupported() && ( ! defined( 'MATOMO_SUPPORT_ASYNC_ARCHIVING' ) || MATOMO_SUPPORT_ASYNC_ARCHIVING );
+ }
+
+ public function is_async_archiving_disabled_by_option() {
+ return (bool) $this->get_global_option( self::DISABLE_ASYNC_ARCHIVING_OPTION_NAME );
+ }
}
diff --git a/plugins/WordPress/WordPress.php b/plugins/WordPress/WordPress.php
index 13c5a470c..8af6d31b2 100644
--- a/plugins/WordPress/WordPress.php
+++ b/plugins/WordPress/WordPress.php
@@ -13,6 +13,7 @@
use Piwik\API\Request;
use Piwik\Common;
use Piwik\FrontController;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugin;
use Piwik\Plugin\Manager;
@@ -21,6 +22,7 @@
use Piwik\Url;
use Piwik\Widget\WidgetsList;
use WpMatomo\Bootstrap;
+use WpMatomo\Settings;
if (!defined( 'ABSPATH')) {
exit; // if accessed directly
@@ -158,7 +160,8 @@ public function supportsAsync(&$supportsAsync)
|| (defined('WP_DEBUG') && WP_DEBUG)
|| !empty($_SERVER['MATOMO_WP_ROOT_PATH'])
|| !matomo_has_compatible_content_dir()
- || (defined( 'MATOMO_SUPPORT_ASYNC_ARCHIVING') && !MATOMO_SUPPORT_ASYNC_ARCHIVING)
+ || (defined( 'MATOMO_SUPPORT_ASYNC_ARCHIVING') && !MATOMO_SUPPORT_ASYNC_ARCHIVING)
+ || $this->isAsyncArchivingDisabledBySetting()
) {
// console wouldn't really work in multi site mode... therefore we prefer to archive in the same request
// WP_DEBUG also breaks things since it's logging things to stdout and then safe unserialise doesn't work
@@ -168,6 +171,12 @@ public function supportsAsync(&$supportsAsync)
}
}
+ private function isAsyncArchivingDisabledBySetting()
+ {
+ $settings = \WpMatomo::$settings;
+ return $settings->is_async_archiving_disabled_by_option();
+ }
+
public function onHeader(&$out)
{
$out .= '';