In the WordPress plugin, some of our users have in their log files something like:
2022/12/22 11:24:55 [error] 9314<a href='/9314'>#9314</a>: *432825 FastCGI sent in stderr: "PHP message: [xxxxxx.de] Error in Matomo: This feature is not available" while reading response header from upstream, client: 157.90.0.0, server: xxxxxx.de, request: "GET /wp-content/plugins/matomo/app/?module=Installation&action=getEmptyPageForSystemCheck HTTP/1.1", upstream: "fastcgi://unix:/var/run/wordpress.php-fpm.sock:", host: "xxxxxx.de", referrer: "https://xxxxxxx.de/wp-content/plugins/matomo/app/?module=Installation&action=getEmptyPageForSystemCheck"
Do not have any error.
Error in the webserver log file.
This call is made here: https://github.com/matomo-org/matomo/blob/702018832517a64837d256875a64e0039b37ac0f/plugins/Diagnostics/Diagnostic/PageSpeedCheck.php#L54-L87
Unfortunately, the Installation plugin is disabled in the WordPress plugin: all Installation plugin requests throw an exception: https://github.com/matomo-org/matomo-for-wordpress/blob/03db1ea2f16073c0d6a2c09b17a3953985a39b57/plugins/WordPress/WordPress.php#L337-L341
So this isPageSpeedEnabled will always fail in an error.
Can you add in the check a constant verification to check if we can process this check? We could then disable it in the plugin and avoid this error.
1.
2.
@mattmary It might be enough to not perform the check if the Installation plugin is not enabled. Feel free to test that and provide a PR for that.
Hello @sgiehl
Sorry, my sentence was not really accurate: by disabled, I meant that all these requests will fail (but the plugin is not disabled): some of the natives actions lead to an exception:
https://github.com/matomo-org/matomo-for-wordpress/blob/34baa9e901f7481bbd82e019ef2cae1d061b57a6/plugins/WordPress/WordPress.php#L330-L362
So I was wondering if we could use a constant to bypass this test? For example, testing if MATOMO_DISABLE_PAGE_TESTSPEED and define it in the WordPress plugin?
Would it be acceptable for you?
Is it a standard way to process in Matomo? If yes, do you have a constant naming convention?
Otherwise, we could also disable this plugin when creating the WordPress plugin release and test like you said if the plugin is enabled? Maybe this second solution is more elegant and would also manage the case that this plugin would have been disabled in Matomo on premise.
Do you have an example of plugin deactivation?
Please share your thoughts
Matthieu
@mattmary You can easily disable certain diagnostic checks using DI by adding something like below to a config.php
:
return [
'diagnostics.disabled' => \DI\add([
\DI\get(\Piwik\Plugins\Diagnostics\Diagnostic\PageSpeedCheck::class),
]),
];
Thank you, @sgiehl !
@tsteur, I can see in the plugin config.php file there are some instructions for the diagnostic plugin: https://github.com/matomo-org/matomo-for-wordpress/blob/34baa9e901f7481bbd82e019ef2cae1d061b57a6/config/config.php#L119
Does it mean we can't disable it? (Additionally, can you explain to me where it is used in the plugin?)
Yes, you can disable it there as well. Either same way as @sgiehl mentioned or similarly to the existing logic.