matomo-org / matomo-for-wordpress

Get a fully functioning Matomo Analytics for your WordPress. Star us on Github? +1. Matomo is the leading open alternative to Google Analytics that gives you full control over your data. Privacy is built-in. 100% data ownership, no one else can see your data. We love Pull Requests!
https://matomo.org
GNU General Public License v3.0
120 stars 25 forks source link

Password confirmation in Matomo admin does not work when 2FA WP plugin is used #1127

Open Artim96 opened 3 months ago

Artim96 commented 3 months ago

I'm experiencing this issue: https://matomo.org/faq/how-to-fix-the-current-password-you-entered-is-not-correct-in-the-plugin-releases-4-12-and-4-13/

As it persists after synchronizing users, I tried that last step. I replaced all content of the file after <?php, yet I get the error

An error of type E_PARSE was caused in line 18 of the file /var/www/wordpress/fsmuw/wp-content/plugins/matomo/config/config.php. Error message: syntax error, unexpected token “,”

diosmosis commented 3 months ago

Hi @Artim96, it looks like the file on that webpage is being cutoff. Unfortunately I can't edit the content right now. The replacement file content should be:

<?php
if (!defined( 'ABSPATH')) {
    exit; // if accessed directly
}
use Piwik\Cache;
use Piwik\Container\StaticContainer;
use Piwik\Option;
use Piwik\Plugin\API;
use WpMatomo\Capabilities;
use WpMatomo\Paths;
use WpMatomo\Settings;
return array(
    'path.tmp' => function () {
        $paths = new \WpMatomo\Paths();
        return $paths->get_tmp_dir();
    },
    'path.misc.user' => function () {
        $paths = new \WpMatomo\Paths();
        return $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir()) . '/';
    },
    'log.handlers' => array(), // required in the console
    'EnableDbVersionCheck' => false,
    'path.geoip2' => function () {
        $paths = new \WpMatomo\Paths();
        return $paths->get_gloal_upload_dir_if_possible('DBIP-City.mmdb') . '/';
    },
    // we want to avoid the regular monolog logger as it could interfere with other plugins maybe. for now lets use a
    // custom logger
    'Psr\Log\LoggerInterface' => DI\get('\Piwik\Plugins\WordPress\Logger'),
    'TagManagerContainerStorageDir' => function () {
        // the location where we store the generated javascript or json container files
        $paths = new \WpMatomo\Paths();
        return rtrim('/'. $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir().'/'), '/');
    },
    'TagManagerContainerWebDir' => function () {
        // the location where we store the generated javascript or json container files
        $paths = new \WpMatomo\Paths();
        return rtrim('/'. $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir().'/'), '/');
    },
    'Piwik\Plugins\Login\PasswordVerifier' => DI\autowire('Piwik\Plugins\WordPress\WpPasswordVerifier'),
    'Piwik\Session\SessionAuth' => DI\autowire('Piwik\Plugins\WordPress\SessionAuth'),
    'Piwik\Auth' => DI\autowire('Piwik\Plugins\WordPress\Auth'),
    \Piwik\Config::class => DI\decorate(function ($previous) {

        \Piwik\Plugins\TagManager\TagManager::$enableAutoContainerCreation = false;
        if (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN) {
            $general = $previous->General;
            $general['force_ssl'] = 1;
            $general['assume_secure_protocol'] = 1;
            $previous->General = $general;
        }
        $database = $previous->database;
        $previous->database = \WpMatomo\Installer::get_db_infos($database);
        $paths = new Paths();
        if ( file_exists( $paths->get_config_ini_path() ) ) {
            $general = $previous->General;
            if (defined('MATOMO_TRIGGER_BROWSER_ARCHIVING')) {
                $general['enable_browser_archiving_triggering'] = (int) MATOMO_TRIGGER_BROWSER_ARCHIVING;
            }
            $matomo_salt_key = Settings::OPTION_PREFIX . 'matomo_salt';
            $matomo_salt = get_option($matomo_salt_key); // needs to be per site!
            if (!$matomo_salt) {
                $matomo_salt = \Piwik\Common::getRandomString(32);
                update_option($matomo_salt_key, $matomo_salt, true);
            }
            $general['salt'] = $matomo_salt;
            if (empty($general['trusted_hosts'])) {
                $general['trusted_hosts'] = array();
            }
            $site_url = site_url();
            if (!in_array($site_url, $general['trusted_hosts'])) {
                $general['trusted_hosts'][] = $site_url;
            }
            $previous->General = $general;
            if (empty($GLOBALS['MATOMO_SWITCH_BLOG_SET_UP'])) {
                // only execute it once since we might init this several times...
                $GLOBALS['MATOMO_SWITCH_BLOG_SET_UP'] = true;
                add_action('switch_blog', function ($new_blog, $prev_blog) {
                    if ($new_blog == $prev_blog) {
                        return;
                    }
                    // ensure correct path to config is set, ensure to update tables_prefix etc.
                    $container = StaticContainer::getContainer();
                    $container->set(\Piwik\Application\Kernel\GlobalSettingsProvider::class, $container->make(\Piwik\Application\Kernel\GlobalSettingsProvider::class));
                    $container->set(\Piwik\Config::class, $container->make(\Piwik\Config::class));
                    Option::clearCache();
                    \Piwik\Site::clearCache();
                    Cache::getTransientCache()->flushAll();
                    API::unsetAllInstances();
                }, 10, 2);
            }
        }
        return $previous;
    }),
    'Piwik\Mail\Transport' => DI\autowire('WpMatomo\Email'),
    'Piwik\Plugins\CustomJsTracker\TrackerUpdater' => DI\decorate(function ($previous) {
        /** @var \Piwik\Plugins\CustomJsTracker\TrackerUpdater $previous */
        $paths = new Paths();
        $dir = $paths->get_matomo_js_upload_path();
        $previous->setToFile($dir);
        return $previous;
    }),
    'diagnostics.optional' => DI\decorate(function ($checks) {
        foreach ($checks as $index => $check) {
            if ($check && is_object($check)) {
                $class_name = get_class($check);
                if ($class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\ForceSSLCheck'
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\LoadDataInfileCheck'
                    || $class_name === 'Piwik\Plugins\CustomJsTracker\Diagnostic\TrackerJsCheck'
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\RequiredPrivateDirectories' // it doesn't resolve config path correctly as it is outside matomo dir etc
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\RecommendedPrivateDirectories' // tmp check doesn't work so far see matomo-org/matomo#18684
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\CronArchivingCheck'
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\FileIntegrityCheck') {
                    $checks[$index] = null;
                }
            }
        }
        return array_values(array_filter($checks));
    }),
    'observers.global' => DI\add(array(
        array('FrontController.modifyErrorPage', DI\value(function (&$result, $ex) {
            if (!empty($ex) && is_object($ex) && $ex instanceof \Piwik\Exception\NoWebsiteFoundException) {
                // try to repair itself in case for some reason the site was not yet synced... on next reload it would
                // then work
                $sync = new \WpMatomo\Site\Sync(new Settings());
                $sync->sync_current_site();
            }
            if (!empty($ex)
                && is_object($ex)
                && $ex instanceof \Piwik\Exception\NoPrivilegesException
                && is_user_logged_in()) {
                if (current_user_can(Capabilities::KEY_VIEW)) {
                    // some error... it looks like user should by synced but isn't yet
                    // could happen eg when in network activated mode the super admin changes permission and another
                    // user from a blog wants to access the UI while not all users are synced just yet
                    // try to repair itself in case for some reason the user was not yet synced... on next reload it would
                    // then work
                    $sync = new \WpMatomo\User\Sync();
                    $sync->sync_current_users();
                }
            }
        })),
        array('Db.getDatabaseConfig', DI\value(function (&$config) {
            // we don't want to save these and instead detect them on demand.
            // for security reasons etc we don't want to duplicate these values
            include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
        })),
        array('Tracker.getDatabaseConfig', DI\value(function (&$configDb) {
            // we don't want to save these and instead detect them on demand.
            // for security reasons etc we don't want to duplicate these values
            include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
        })),
        array('Config.beforeSave', DI\value(function (&$values) {
            // we don't want to save these and instead detect them on demand.
            // for security reasons etc we don't want to duplicate these values
            unset($values['database']['host']);
            unset($values['database']['username']);
            unset($values['database']['password']);
            unset($values['database']['dbname']);
            unset($values['database']['tables_prefix']);
            unset($values['database']['charset']);
            unset($values['Plugins']);
            unset($values['General']['enable_users_admin']);
            unset($values['General']['enable_sites_admin']);
            unset($values['General']['salt']);
        })),
        array('Login.userRequiresPasswordConfirmation', DI\value(function (&$requiresPasswordConfirmation, $login) {$requiresPasswordConfirmation = false;})),
        ))
);

Note that this will only work in pre-5.0 versions.

diosmosis commented 3 months ago

If you are experiencing this on the latest version, can you please provide your Matomo's system report: https://matomo.org/faq/wordpress/how-do-i-find-and-copy-the-system-report-in-matomo-for-wordpress/ ?

Artim96 commented 3 months ago

Yes, I experience it on the latest version:

                  # Matomo

* Matomo plugin version: 5.0.6
* Config exists and is writable: Yes (“$abs_path/wp-content/uploads/matomo/config/config.ini.php” )
* JS Tracker exists and is writable: Yes (“$abs_path/wp-content/uploads/matomo/matomo.js” )
* Plugin directories: Yes ([{“pluginsPathAbsolute”:“$abs_path\/wp-content\/plugins\/matomo\/plugins”, “webrootDirRelativeToMatomo”:“..\/plugins”}])
* Tmp directory writable: Yes ($abs_path/wp-content/cache/matomo)
* Matomo version: 5.0.2
* Matomo Blog idSite: 1
* Installed Matomo version: 1.1.3 (Install date: 2020-07-20 17:24:51)
* Upgrades outstanding: No
* Upgrade in progress: No

## Endpoints

* Matomo JavaScript Tracker URL:  ($site_url/wp-content/uploads/matomo/matomo.js)
* Matomo JavaScript Tracker - WP Rest API: ($site_url/wp-json/matomo/v1/hit/)
* Matomo HTTP Tracking API: ($site_url/wp-content/plugins/matomo/app/matomo.php)
* Matomo HTTP Tracking API - WP Rest API: ($site_url/wp-json/matomo/v1/hit/)

## Crons

* Server time: 2024-06-04 15:35:33
* Blog time: 2024-06-04 17:35:33 (The following data is displayed in the blog time zone)
* Sync users & sites: Next run: 2024-06-05 17:24:50 (23 hours 49 minutes) ( Last started: 2024-06-04 17:35:20 (-13 sec.). Last ended: 2024-06-04 17:35:20 (-13 sec.). Interval: daily)
* Archive: Next run: 2024-06-04 17:38:56 (3 minutes 23s) ( Last started: 2024-06-04 16:46:28 (-49 minutes 5s). Last ended: 2024-06-04 16:46:30 (-49 minutes 3s). Interval: hourly)
* Update GeoIP DB: Next run: 2024-06-29 17:24:50 (24 days 23 hours) ( Last started: 2024-05-30 17:30:03 (-5 days 0 hours). Last ended: 2024-05-30 17:30:06 (-5 days 0 hours). Interval: matomo_monthly)

## Mandatory checks

* PHP version >= 7.2.5: ok 
* PDO extension: ok 
* PDO\MYSQL extension: ok 
* MYSQLI extension: ok 
* Other necessary requirements: ok 
* Required functions: ok 
* Required PHP configuration (php.ini): ok 
* Directories with write access: ok 
* Directories with write access to Tag Manager: ok 

## Optional checks

* 64-bit PHP binary: ok 
* Tracker status: ok 
* Memory limit: ok 
* Time zone: ok 
* Open a URL: ok 
* GD > 2.x + FreeType (graphics): ok 
* Other extensions: ok 
* Other functions: ok 
* File system: ok 
* Last successful completion of archiving: ok 
* Database capabilities: ok 
* Maximum packet size: ok 
* Location detection: ok 
* Update via HTTPS: ok 
* Mobile Messaging SMS Provider: ok 
* Supports Async Archiving: Yes
* Async Archiving Disabled in Setting: No
* Location provider ID: geoip2php
* Location provider available: Yes
* Location provider working: Yes
* Had visit in last 5 days: Yes
* Matomo URL: Yes ($site_url/wp-content/plugins/matomo/app)

## Matomo Settings

* Track mode: default
* Track ecommerce: No
* Track codeposition: header
* Track api endpoint: default
* Track js endpoint: default
* Version history: 5.0.6, 5.0.5, 5.0.4, 5.0.3, 5.0.2
* Core version: 5.0.2
* Last tracking settings update: 1717491568
* Last settings update: 1717491662
* Track noscript: Yes
* Track content: visible
* Track ecommerce: No
* Track search: Yes
* Track 404: Yes
* Disable cookies: Yes
* Limit cookies visitor: 2629800
* Limit cookies referral: 2629800
* Show get started page: 0
* Track jserrors: Yes

## Logs

* archive_boot: 2024-06-04 16:45:20 (Matomo error: 8192: Creation of dynamic property R34NoNo::$settings is deprecated in $abs_path/wp-content/plugins/no-nonsense/class-r34nono.php:20 => bootstrap. php:59; bootstrap.php:88; class-r34nono.php:20; no-nonsense.php:45; class-wp-hook.php:324; class-wp-hook.php:348; plugin.php:517; wp-settings.php:550; wp-config.php:132; wp-load.php:50; bootstrap.php:98; console:11;)
* archive_boot: 2024-06-04 16:45:22 (Matomo error: 8192: Creation of dynamic property R34NoNo::$settings is deprecated in $abs_path/wp-content/plugins/no-nonsense/class-r34nono.php:20 => bootstrap. php:59; bootstrap.php:88; class-r34nono.php:20; no-nonsense.php:45; class-wp-hook.php:324; class-wp-hook.php:348; plugin.php:517; wp-settings.php:550; wp-config.php:132; wp-load.php:50; bootstrap.php:98; console:11;)
* archive_boot: 2024-06-04 17:30:11 (Matomo error: 8192: Creation of dynamic property R34NoNo::$settings is deprecated in $abs_path/wp-content/plugins/no-nonsense/class-r34nono.php:20 => bootstrap. php:59; bootstrap.php:88; class-r34nono.php:20; no-nonsense.php:45; class-wp-hook.php:324; class-wp-hook.php:348; plugin.php:517; wp-settings.php:550; wp-config.php:132; wp-load.php:50; bootstrap.php:98; console:11;)
* archive_boot: 2024-06-04 17:30:18 (Matomo error: 8192: Creation of dynamic property R34NoNo::$settings is deprecated in $abs_path/wp-content/plugins/no-nonsense/class-r34nono.php:20 => bootstrap. php:59; bootstrap.php:88; class-r34nono.php:20; no-nonsense.php:45; class-wp-hook.php:324; class-wp-hook.php:348; plugin.php:517; wp-settings.php:550; wp-config.php:132; wp-load.php:50; bootstrap.php:98; console:11;)
* archive_boot: 2024-06-04 

Translated with DeepL.com (free version)
diosmosis commented 3 months ago

EDIT: Apologies if you tried this immediately, there was a typo I just fixed.

@Artim96 For the latest version, you can use the following replacement to disable password confirmation:

<?php

if (!defined( 'ABSPATH')) {
    exit; // if accessed directly
}

use Piwik\Cache;
use Piwik\Container\StaticContainer;
use Piwik\Option;
use Piwik\Plugin\API;
use WpMatomo\Capabilities;
use WpMatomo\Paths;
use WpMatomo\Settings;

return array(
    'path.tmp' => function () {
        $paths = new \WpMatomo\Paths();
        return $paths->get_tmp_dir();
    },
    'path.misc.user' => function () {
        $paths = new \WpMatomo\Paths();
        return $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir()) . '/';
    },
    'log.handlers' => array(), // required in the console
    'EnableDbVersionCheck' => false,
    'path.geoip2' => function () {
        $paths = new \WpMatomo\Paths();
        return $paths->get_gloal_upload_dir_if_possible('DBIP-City.mmdb') . '/';
    },
    // we want to avoid the regular monolog logger as it could interfere with other plugins maybe. for now lets use a
    // custom logger
    'Piwik\Log\LoggerInterface' => \Piwik\DI::get('\Piwik\Plugins\WordPress\Logger'),
    // following two entries used by CoreAdminHome.runCronArchiving
    'log.short.format' => '%level% %tag%[%datetime%] %message%',
    'Piwik\Plugins\Monolog\Formatter\LineMessageFormatter' => \Piwik\DI::create('Piwik\Plugins\Monolog\Formatter\LineMessageFormatter')
        ->constructor(\Piwik\DI::get('log.short.format')),
    'TagManagerContainerStorageDir' => function () {
        if (defined('MATOMO_TAG_MANAGER_STORAGE_DIR')) {
            return MATOMO_TAG_MANAGER_STORAGE_DIR;
        }

        // the location where we store the generated javascript or json container files
        $paths = new \WpMatomo\Paths();
        return rtrim('/'. $paths->get_relative_dir_to_matomo($paths->get_upload_base_dir().'/', @realpath(MATOMO_ANALYTICS_FILE)), '/');
    },
    'TagManagerContainerWebDir' => function () {
        if (defined('MATOMO_TAG_MANAGER_WEB_DIR')) {
            return MATOMO_TAG_MANAGER_WEB_DIR;
        }

        // the location where we store the generated javascript or json container files
        $paths = new \WpMatomo\Paths();
        return rtrim('/'. matomo_rel_path($paths->get_upload_base_dir() . '/', WP_PLUGIN_DIR . '/matomo/app'), '/');
    },
    'Piwik\Plugins\Login\PasswordVerifier' => \Piwik\DI::autowire('Piwik\Plugins\WordPress\WpPasswordVerifier'),
    'Piwik\Session\SessionAuth' => \Piwik\DI::autowire('Piwik\Plugins\WordPress\SessionAuth'),
    'Piwik\Auth' => \Piwik\DI::autowire('Piwik\Plugins\WordPress\Auth'),
    \Piwik\Config::class => \Piwik\DI::decorate(function ($previous) {

        \Piwik\Plugins\TagManager\TagManager::$enableAutoContainerCreation = false;

        if (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN) {
            $general = $previous->General;
            $general['force_ssl'] = 1;
            $general['assume_secure_protocol'] = 1;
            $previous->General = $general;
        }

        $database = $previous->database;
        $previous->database = \WpMatomo\Installer::get_db_infos($database);

        $paths = new Paths();
        if ( file_exists( $paths->get_config_ini_path() ) ) {
            $general = $previous->General;

            if (defined('MATOMO_TRIGGER_BROWSER_ARCHIVING')) {
                $general['enable_browser_archiving_triggering'] = (int) MATOMO_TRIGGER_BROWSER_ARCHIVING;
            }

            $matomo_salt_key = Settings::OPTION_PREFIX . 'matomo_salt';
            $matomo_salt = get_option($matomo_salt_key); // needs to be per site!
            if (!$matomo_salt) {
                $matomo_salt = \Piwik\Common::getRandomString(32);
                update_option($matomo_salt_key, $matomo_salt, true);
            }

            $general['salt'] = $matomo_salt;

            if (empty($general['trusted_hosts'])) {
                $general['trusted_hosts'] = array();
            }
            $site_url = site_url();
            if (!in_array($site_url, $general['trusted_hosts'])) {
                $general['trusted_hosts'][] = $site_url;
            }
            $previous->General = $general;

            if (empty($GLOBALS['MATOMO_SWITCH_BLOG_SET_UP'])) {
                // only execute it once since we might init this several times...
                $GLOBALS['MATOMO_SWITCH_BLOG_SET_UP'] = true;

                add_action('switch_blog', function ($new_blog, $prev_blog) {
                    if ($new_blog == $prev_blog) {
                        return;
                    }
                    // ensure correct path to config is set, ensure to update tables_prefix etc.
                    $container = StaticContainer::getContainer();
                    $container->set(\Piwik\Application\Kernel\GlobalSettingsProvider::class, $container->make(\Piwik\Application\Kernel\GlobalSettingsProvider::class));
                    $container->set(\Piwik\Config::class, $container->make(\Piwik\Config::class));
                    Option::clearCache();
                    \Piwik\Site::clearCache();
                    Cache::getTransientCache()->flushAll();
                    API::unsetAllInstances();
                }, 10, 2);
            }
        }

        return $previous;
    }),
    'Piwik\Mail\Transport' => \Piwik\DI::autowire('WpMatomo\Email'),
    'Piwik\Plugins\CustomJsTracker\TrackerUpdater' => \Piwik\DI::decorate(function ($previous) {
        /** @var \Piwik\Plugins\CustomJsTracker\TrackerUpdater $previous */

        $paths = new Paths();
        $dir = $paths->get_matomo_js_upload_path();

        $previous->setToFile($dir);

        return $previous;
    }),
    'diagnostics.optional' => \Piwik\DI::decorate(function ($checks) {
        foreach ($checks as $index => $check) {
            if ($check && is_object($check)) {
                $class_name = get_class($check);
                if ($class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\ForceSSLCheck'
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\LoadDataInfileCheck'
                    || $class_name === 'Piwik\Plugins\CustomJsTracker\Diagnostic\TrackerJsCheck'
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\RequiredPrivateDirectories' // it doesn't resolve config path correctly as it is outside matomo dir etc
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\RecommendedPrivateDirectories' // tmp check doesn't work so far see matomo-org/matomo#18684
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\CronArchivingCheck'
                    || $class_name === 'Piwik\Plugins\Diagnostics\Diagnostic\FileIntegrityCheck') {
                    $checks[$index] = null;
                }
            }
        }
        return array_values(array_filter($checks));
    }),
    'diagnostics.disabled'  => \Piwik\DI::add([
        \Piwik\DI::get(\Piwik\Plugins\Diagnostics\Diagnostic\PageSpeedCheck::class),
    ]),
    'observers.global' => \Piwik\DI::add(array(
        array('FrontController.modifyErrorPage', \Piwik\DI::value(function (&$result, $ex) {
            if (!empty($ex) && is_object($ex) && $ex instanceof \Piwik\Exception\NoWebsiteFoundException) {
                // try to repair itself in case for some reason the site was not yet synced... on next reload it would
                // then work
                $sync = new \WpMatomo\Site\Sync(new Settings());
                $sync->sync_current_site();
            }
            if (!empty($ex)
                && is_object($ex)
                && $ex instanceof \Piwik\Exception\NoPrivilegesException
                && is_user_logged_in()) {
                if (current_user_can(Capabilities::KEY_VIEW)) {
                    // some error... it looks like user should by synced but isn't yet
                    // could happen eg when in network activated mode the super admin changes permission and another
                    // user from a blog wants to access the UI while not all users are synced just yet
                    // try to repair itself in case for some reason the user was not yet synced... on next reload it would
                    // then work
                    $sync = new \WpMatomo\User\Sync();
                    $sync->sync_current_users();
                }
            }
        })),
        array('Db.getDatabaseConfig', \Piwik\DI::value(function (&$config) {
            // we don't want to save these and instead detect them on demand.
            // for security reasons etc we don't want to duplicate these values
            include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
        })),
        array('Tracker.getDatabaseConfig', \Piwik\DI::value(function (&$configDb) {
            // we don't want to save these and instead detect them on demand.
            // for security reasons etc we don't want to duplicate these values
            include_once plugin_dir_path(MATOMO_ANALYTICS_FILE ) . 'classes/WpMatomo/Db/WordPress.php';
        })),
        array('Config.beforeSave', \Piwik\DI::value(function (&$values) {
            // we don't want to save these and instead detect them on demand.
            // for security reasons etc we don't want to duplicate these values
            unset($values['database']['host']);
            unset($values['database']['username']);
            unset($values['database']['password']);
            unset($values['database']['dbname']);
            unset($values['database']['tables_prefix']);
            unset($values['database']['charset']);
            unset($values['Plugins']);
            unset($values['General']['enable_users_admin']);
            unset($values['General']['enable_sites_admin']);
            unset($values['General']['salt']);
        })),
        array('Login.userRequiresPasswordConfirmation', \Piwik\DI::value(function (&$requiresPasswordConfirmation, $login) {$requiresPasswordConfirmation = false;})),
    )),

);

We'll see if we can figure out why the problem is still occurring for you on the latest version. I may have follow up questions for you.

Artim96 commented 3 months ago

This doesn't work. Issue is, Wordpress only talks about a critical error and that its being sent by mail. But while any other mail is being sent by mail (including the one form the OP), but this one doesn't. Also, sadly Wordpress ignores WP_DEBUG_LOG for a few months now.

diosmosis commented 3 months ago

I noticed the list of plugins is missing from your system report, are you able to provide the other WordPress plugins in your install? One of them may be interfering with Matomo functionality.

This doesn't work.

You used the updated script I posted, correct? The one with this text array('Login.userRequiresPasswordConfirmation', \Piwik\DI::value?

Artim96 commented 3 months ago

It seems some caching was the issue - either by Autoptimize or a Redis Plugin. It works now.

diosmosis commented 3 months ago

@Artim96 Since you did not post the full plugin list for your instance, I'm assuming you aren't interested in finding out why the password confirmation wasn't working orignally? The replacement script simply disables the feature. (Or maybe you meant the original problem was caused by Autoptimize or Redis Plugin?)

Artim96 commented 3 months ago

Nope, just the changed script is working now.

* AuthLDAP: 2.6.2
* Autoptimize: 3.1.11
* Clarity - Ad blocker for WordPress: 1.3.231102
* Easy Custom Sidebars: 2.0.1
* Easy Updates Manager: 9.0.17 (Network enabled)
* Embed Code - Insert Header & Footer code: 2.0.4
* Events Manager: 6.4.7.3
* Forminator: 1.31.0
* Matomo Analytics - Ethical Stats. Powerful Insights.: 5.0.6
* No Nonsense: 3.3.2.1
* PublishPress Revisions: 3.5.9
* Redirection: 5.4.2
* Redis Object Cache: 2.5.2 (Network enabled)
* Safe SVG: 2.2.4
* Smart Slider 3: 3.5.1.23
* TranslatePress - Multilingual: 2.7.8
* Two Factor Authentication: 1.14.17
* User Role Editor: 4.64.2
* WebP Express: 0.25.9 (Network enabled)
* WP Mail SMTP: 4.0.1
* Active Plugins: 19 (authldap:2.6.2 autoptimize:3.1.11 clarity-ad-blocker:1.3.231102 easy-custom-sidebars:2.0.1 embed-code:2.0.4 events-manager:6.4.7.3 forminator:1.31.0 matomo:5.0.6 no-nonsense:3.3.2.1 redis-cache:2.5.2 revisionary:3.5.9 safe-svg:2.2.4 smart-slider-3:3.5.1.23 stops-core-theme-and-plugin-updates:9.0.17 translatepress-multilingual:2.7.8 two-factor-authentication:1.14.17 user-role-editor:4.64.2 webp-express:0.25.9 wp-mail-smtp:4.0.1)
* Theme: customify (customify)
diosmosis commented 3 months ago

Looks like this is an compatibility issue with two factor auth plugins. Disabling the feature is the only workaround for now.

Artim96 commented 3 months ago

Makes sense. Maybe the authentication mechanism of WordPress can somehow be leveraged in the future?

diosmosis commented 3 months ago

Matomo for WordPress authenticates through WordPress already. Thanks for the bug report, we'll look into it when we can.