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
119 stars 25 forks source link

Matomo doesn't work with WordPress: missing Logger.php file #711

Closed TfGmohm closed 1 year ago

TfGmohm commented 1 year ago

I get this error and have no idea how to handle it. Tried now different PHP Versions (8.0, 8.1, 8.4):

Matomo Archive Warnings: 'Got invalid response from API request: ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2023-01-13&format=json&trigger=archivephp. Response was \'PHP Warning: require_once(classes/WpMatomo/Logger.php): Failed to open stream: No such file or directory in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90 PHP Fatal error: Uncaught Error: Failed opening required \'classes/WpMatomo/Logger.php\' (include_path=\'.:/usr/share/php\') in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php:90

mattmary commented 1 year ago

Hello @TfGmohm

Sorry to read that you encounter an issue with our plugin. It looks like you have one file missing. Could you try to uninstall and reinstall the plugin? (Note: by default, removing the plugin will delete all your Matomo data. If you have tracking data and want to keep them, please uncheck the "Matomo Analytics > Settings > Advanced > Delete all data on uninstall" Checkbox Screenshot from 2023-01-17 08-45-23)

TfGmohm commented 1 year ago

First of all: Thanks for helping me.

I uninstalled and reinstalled the plugin. The result is unfortunately the same.

The diagnotics says now:

 Got invalid response from API request: ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2023-01-17&format=json&trigger=archivephp. Response was \'PHP Warning: require_once(classes/WpMatomo/Logger.php): Failed to open stream: No such file or directory in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90 PHP Fatal error: Uncaught Error: Failed opening required \'classes/WpMatomo/Logger.php\' (include_path=\'.:/usr/share/php\') in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php:90 Stack trace: #0 [internal function]: matomo_plugin_autoloader() #1 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(52): class_exists() #2 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(85): matomo_log_message_no_display() #3 $abs_path/wp-content/plugins/matomo/shared.php(36): {closure}() #4 $abs_path/wp-content/plugins/matomo/shared.php(36): require_once(\'...\') #5 $abs_path/wp-content/plugins/matomo/classes/WpMatomo.php(50): matomo_plugin_autoloader() #6 $abs_path/wp-content/plugins/matomo/matomo.php(212): WpMatomo->__construct() #7 $abs_path/wp-settings.php(447): include_once(\'...\') #8 $abs_path/wp-config.php(88): require_once(\'...\') #9 $abs_path/wp-load.php(50): require_once(\'...\') #10 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(95): require_once(\'...\') #11 $abs_path/wp-content/plugins/matomo/app/console(11): require_once(\'...\') #12 {main} thrown in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90

mattmary commented 1 year ago

Hello @TfGmohm

Thank you.

How did you install our plugin?

Can you also check if you have the following file: ./wp-content/plugins/matomo/classes/WpMatomo/Admin/CookieConsent.php Which permissions are defined on this file and on the ./wp-content/plugins/matomo/classes/WpMatomo/Admin folder?

Kind regards

Mat

TfGmohm commented 1 year ago

I installed the plugin from WP Admin Backend.

CookieConsent.php is there with permissions Write/Read/Read

Matomo/Admin Folder has 755.

Kind regards, Mohm

mattmary commented 1 year ago

Hello @TfGmohm

Thank you. Which is your hosting provider? Would you mind asking them if they use a security mechanism which check and quarantine content on plugins install? Could you try to download our plugin from GitHub and upload it in the wp-content/plugins/matomo folder and check if it fixes your issue? Kind regards

Mat

TfGmohm commented 1 year ago

Since we run a dedicated server there is no hosting provider with restrictions.

I reinstalled the plugin again AND I download the plugin from GitHub and upload it to the server overwriting all files there.

The result is still the same:

8 total errors during this script execution, please investigate and try and fix these errors. => CronArchive.php:625; CronArchive.php:618; CronArchive.php:280; Access.php:670; CronArchive.php:284; ScheduledTasks.php:332; class-wp-hook.php:306; class-wp-hook.php:332; plugin.php:565; wp-cron.php:188;

Got invalid response from API request: ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2023-01-19&format=json&trigger=archivephp. Response was \'PHP Warning: require_once(classes/WpMatomo/Logger.php): Failed to open stream: No such file or directory in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90 PHP Fatal error: Uncaught Error: Failed opening required \'classes/WpMatomo/Logger.php\' (include_path=\'.:/usr/share/php\') in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php:90 Stack trace: #0 [internal function]: matomo_plugin_autoloader() #1 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(52): class_exists() #2 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(85): matomo_log_message_no_display() #3 $abs_path/wp-content/plugins/matomo/shared.php(36): {closure}() #4 $abs_path/wp-content/plugins/matomo/shared.php(36): require_once(\'...\') #5 $abs_path/wp-content/plugins/matomo/classes/WpMatomo.php(50): matomo_plugin_autoloader() #6 $abs_path/wp-content/plugins/matomo/matomo.php(212): WpMatomo->__construct() #7 $abs_path/wp-settings.php(447): include_once(\'...\') #8 $abs_path/wp-config.php(88): require_once(\'...\') #9 $abs_path/wp-load.php(50): require_once(\'...\') #10 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(95): require_once(\'...\') #11 $abs_path/wp-content/plugins/matomo/app/console(11): require_once(\'...\') #12 {main} thrown in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90

mattmary commented 1 year ago

Hello @TfGmohm

Thank you. This error concerns your archiving process. But are you able to view the Matomo plugin pages in the WordPress back-office? If yes, could you post your system report available from the menu "Matomo Analytics > Diagnostics"? Are you also able to run the archiving process from the "Matomo Analytics > Diagnostics > Troubleshooting" page? Does it end in an error? And final question: do you plan to use the Matomo widgets available from the "Matomo Analytics > Summary" menu?

Kind regards

Mat

TfGmohm commented 1 year ago

Hi Mat, I can see the Matomo pages at the WP backend. If I start the archiving process from Troubleshooting it end in the same error as above. End I don't plan to use Matomo widgets.

System report:

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

Matomo Plugin Version | 4.13.0 |   -- | -- | -- Config exists and is writable. | Yes | "/var/www/vhosts/cx.vx.com/httpdocs/wp-content/uploads/matomo/config/config.ini.php" JS Tracker exists and is writable. | Yes | "/var/www/vhosts/cx.vx.com/httpdocs/wp-content/uploads/matomo/matomo.js" Plugin directories | Yes | [{"pluginsPathAbsolute":"\/var\/www\/vhosts\/cx.vx.com\/httpdocs\/wp-content\/plugins\/matomo\/plugins","webrootDirRelativeToMatomo":"..\/"}] Tmp directory writable | Yes | /var/www/vhosts/cx.vx.com/httpdocs/wp-content/cache/matomo Matomo Version | 4.13.0 |   Matomo Blog idSite | 1 |   Matomo Install Version | 4.13.0 | Install date: 2023-01-19 09:39:24 Upgrades outstanding | No |   Upgrade in progress | No |   Endpoints Matomo JavaScript Tracker URL |   | https://cx.vx.com/wp-content/uploads/matomo/matomo.js Matomo JavaScript Tracker - WP Rest API |   | https://cx.vx.com/wp-json/matomo/v1/hit/ Matomo HTTP Tracking API |   | https://cx.vx.com/wp-content/plugins/matomo/app/matomo.php Matomo HTTP Tracking API - WP Rest API |   | https://cx.vx.com/wp-json/matomo/v1/hit/ Crons Server time | 2023-01-20 09:08:57 |   Blog time | 2023-01-20 10:08:57 | Below dates are shown in blog timezone Sync users & sites | Next run: 2023-01-21 09:41:56 (23 hours 32 min) | Last started: 2023-01-20 10:04:44 (-4 min 13s). Last ended: 2023-01-20 10:04:44 (-4 min 13s). Interval: daily Archive | Next run: 2023-01-20 10:39:34 (30 min 37s) | Last started: 2023-01-20 10:04:42 (-4 min 15s). Last ended: 2023-01-20 10:04:44 (-4 min 13s). Interval: hourly Update GeoIP DB | Next run: 2023-02-18 09:41:56 (28 days 23 hours) | Last started: 2023-01-19 09:41:57 (-1 days 0 hours). Last ended: 2023-01-19 09:41:58 (-1 days 0 hours). Interval: matomo_monthly Mandatory checks PHP version >= | ok |   PDO extension | ok |   PDO\MYSQL extension | ok |   MYSQLI extension | ok |   Other required extensions | ok |   Required functions | ok |   Required PHP configuration (php.ini) | ok |   Directories with write access | ok |   Directories with write access for Tag Manager | ok |   Optional checks 64-bit PHP Binary | ok |   Tracker status | ok |   Memory limit | ok |   Time zone | ok |   Open URL | ok |   PageSpeed is turned off | ok |   GD > 2.x + FreeType (graphics) | ok |   Other extensions | ok |   Other functions | ok |   Filesystem | ok |   Last Successful Archiving Completion | warning | Archiving last ran successfully on Thursday, January 19, 2023 08:39:36 which is 1 days 00:29:21 ago Database abilities | ok |   Max Packet Size | warning | It is recommended to configure a 'max_allowed_packet' size in your MySQL database of at least 64MB. Configured is currently 16MB. Geolocation | ok |   Update over HTTPS | ok |   Supports Async Archiving | Yes |   Location provider ID | geoip2php |   Location provider available | Yes |   Location provider working | Yes |   Had visit in last 5 days | Yes |   Matomo URL | Yes | https://cx.vx.com/wp-content/plugins/matomo/app/ Matomo Settings Track mode | default |   Track codeposition | footer |   Track api endpoint | default |   Track js endpoint | default |   Version history | 4.13.0 |   Core version | 4.13.0 |   Last tracking settings update | 1674117653 |   Last settings update | 1674117653 |  

 

Greetings, Mohm

mattmary commented 1 year ago

Hello @TfGmohm

Some fields are missing in this system report. Could you post it again following this procedure, please? https://matomo.org/faq/wordpress/how-do-i-find-and-copy-the-system-report-in-matomo-for-wordpress/

Do you use a custom folder for your plugins?

And could you execute the following command and give me the output? cd wp-content/plugins/matomo/app && php ./console list

And finally, could you add the following content into your wp-config.php file and tells me if this solves your issue:

if (!defined('MATOMO_SUPPORT_ASYNC_ARCHIVING')) {
    define('MATOMO_SUPPORT_ASYNC_ARCHIVING', false);
}

Thanks in advance

Kind regards

Mat

TfGmohm commented 1 year ago

Hi @mattmary,

I don't use a custom folder for my plugins.

cd wp-content/plugins/matomo/app && php ./console list gives me this output:

PHP Warning: require_once(classes/WpMatomo/Admin/CookieConsent.php): Failed to open stream: No such file or directory in /var/www/vhosts/cx.vx.com/httpdocs/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90 PHP Fatal error: Uncaught Error: Failed opening required 'classes/WpMatomo/Admin/CookieConsent.php' (include_path='.:/usr/share/php') in /var/www/vhosts/cx.vx.com/httpdocs/wp-content/plugins/matomo/classes/WpMatomo/Settings.php:90 Stack trace:

0 /var/www/vhosts/cx.vx.com/httpdocs/wp-content/plugins/matomo/classes/WpMatomo.php(50): matomo_plugin_autoloader()

1 /var/www/vhosts/cx.vx.com/httpdocs/wp-content/plugins/matomo/matomo.php(212): WpMatomo->__construct()

2 /var/www/vhosts/cx.vx.com/httpdocs/wp-settings.php(447): include_once('...')

3 /var/www/vhosts/cx.vx.com/httpdocs/wp-config.php(88): require_once('...')

4 /var/www/vhosts/cx.vx.com/httpdocs/wp-load.php(50): require_once('...')

5 /var/www/vhosts/cx.vx.com/httpdocs/wp-content/plugins/matomo/app/bootstrap.php(95): require_once('...')

6 /var/www/vhosts/cx.vx.com/httpdocs/wp-content/plugins/matomo/app/console(11): require_once('...')

7 {main}

thrown in /var/www/vhosts/cx.vx.com/httpdocs/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90 <!DOCTYPE html>

WordPress › Error

There has been a critical error on this website.

Learn more about troubleshooting WordPress.

But adding this to the config helped:

if (!defined('MATOMO_SUPPORT_ASYNC_ARCHIVING')) { define('MATOMO_SUPPORT_ASYNC_ARCHIVING', false); }

Thank you so much!

mattmary commented 1 year ago

Hello @TfGmohm

Thank you. And you confirm that the file ./wp-content/plugins/matomo/classes/WpMatomo/Admin/CookieConsent.php exists on your filesystem?

In the mode we have enabled with this constant, the archiving process will be made when you request a Matomo page. Your Matomo pages will be a little bit longer to load. Will try to investigate further why the normal archiving process does not work in your configuration. Could you post your full system report again, please? https://matomo.org/faq/wordpress/how-do-i-find-and-copy-the-system-report-in-matomo-for-wordpress/

Kind regards

Mat

TfGmohm commented 1 year ago

Hello @mattmary

the CookieConsent.php exists in the Admin folder. I re-checked this.

The full system report following the advise:

              # Matomo

Endpoints

Crons

Mandatory checks

Optional checks

Matomo Settings

Logs

WordPress

WordPress Plugins

Server

PHP cli

Database

Browser

MatomoForumNotifications commented 1 year ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/archiving-error-php-fatal-error-failed-opening-required-classes-wpmatomo-logger-php/49278/2

mattab commented 1 year ago

Similar issue happening in https://wordpress.org/support/topic/unable-to-activate-plugin-in-php-8-2-x-environment/

suess-ecbm commented 1 year ago

Please try uncommenting line 90 in file wordpress/wp-content/plugins/matomo/classes/WpMatomo/Admin/Settings.php

//              'cookie_consent'                           => CookieConsent::REQUIRE_NONE,

then try activating the plugin again.

mattmary commented 1 year ago

Hello @suess-ecbm

Unfortunately this approach will modify the default plugin behavior. We do not recommend this approach. @TfGmohm had this problem too and we have been able to fix it by updating the way his archiving process works, But we are trying to find the real origin of this problem as he is not the only one to get this error. We're working on it. Kind regards

Mat

Tperyx commented 1 year ago

Hi, Plugin Matomo for WordPress, last version Tested with PHP 7.4 WP 6.1.1 and PHP 8.0 WP 6.1.1 The archiving of reports has not been working for a few days. Completly uninstall and reinstall the plugin (excluding or including database, loosing all datas), same error. I noticed a difference between Webserver PHP 8.0 and PHP CLI 8.2, could this be the cause ?

Error unserializing the following response from ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2023-01-18&format=json&trigger=archivephp: 'PHP Warning: require_once(classes/WpMatomo/Logger.php): Failed to open stream: No such file or directory in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90 PHP Fatal error: Uncaught Error: Failed opening required 'classes/WpMatomo/Logger.php' (include_path='.:/usr/share/php') in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php:90 Stack trace:

0 [internal function]: matomo_plugin_autoloader()

1 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(52): class_exists()

2 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(85): matomo_log_message_no_display()

3 $abs_path/wp-content/plugins/matomo/shared.php(36): {closure}()

4 $abs_path/wp-content/plugins/matomo/shared.php(36): require_once('…')

5 $abs_path/wp-content/plugins/matomo/classes/WpMatomo.php(50): matomo_plugin_autoloader()

6 $abs_path/wp-content/plugins/matomo/matomo.php(212): WpMatomo->__construct()

7 $abs_path/wp-settings.php(428): include_once('…')

8 $abs_path/wp-config.php(120): require_once('…')

9 $abs_path/wp-load.php(50): require_once('…')

10 $abs_path/wp-content/plugins/matomo/app/bootstrap.php(95): require_once('…')

11 $abs_path/wp-content/plugins/matomo/app/console(11): require_once('…')

12 {main}

thrown in $abs_path/wp-content/plugins/matomo/classes/WpMatomo/Settings.php on line 90

system report here > https://forum.matomo.org/t/archiving-error-php-fatal-error-failed-opening-required-classes-wpmatomo-logger-php/49278

mattmary commented 1 year ago

Hello,

Did you try this solution? https://github.com/matomo-org/matomo-for-wordpress/issues/711#issuecomment-1399657435

Kind regards

Mat

mattmary commented 1 year ago

I close this issue to not flood of notifications everyone. Feel free to open a new one if you encounter a similar issue. Will link it to the main one.

Tperyx commented 1 year ago

Hello,

Thank you very much mattmary, archiving is working again with

if (!defined('MATOMO_SUPPORT_ASYNC_ARCHIVING')) { define('MATOMO_SUPPORT_ASYNC_ARCHIVING', false); }

mattmary commented 1 year ago

Hello @Tperyx @suess-ecbm @TfGmohm

We've just released the 4.13.4 version of our plugin. It includes a fix for this problem. If you've commented the line, you should be able to uncomment it. And if you swtiched to the sync mode, you should now be able to use the async mode too.

Kind regards

Mat