Skip to content
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

"This feature is not available" in WordPress plugin when checking isPageSpeedEnabled() #20134

Closed
mattmary opened this issue Dec 22, 2022 · 5 comments · Fixed by matomo-org/matomo-for-wordpress#709
Labels
Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.

Comments

@mattmary
Copy link
Contributor

In the WordPress plugin, some of our users have in their log files something like:

2022/12/22 11:24:55 [error] 9314#9314: *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"

Expected Behavior

Do not have any error.

Current Behavior

Error in the webserver log file.

Possible Solution

This call is made here:

private function isPageSpeedEnabled()
{
try {
$matomoUrl = SettingsPiwik::getPiwikUrl();
} catch (\Exception $e) {
$matomoUrl = Url::getCurrentUrlWithoutQueryString();
}
if (empty($matomoUrl)) {
// skip this check if we can't determine the matomo url (e.g. on command line)
return false;
}
$url = $matomoUrl . '?module=Installation&action=getEmptyPageForSystemCheck';
try {
$page = Http::sendHttpRequest(
$url,
$timeout = 1,
$userAgent = null,
$destinationPath = null,
$followDepth = 0,
$acceptLanguage = false,
$byteRange = false,
// Return headers
$getExtendedInfo = true
);
} catch (\Exception $e) {
$this->logger->info('Unable to test if mod_pagespeed is enabled: the request to {url} failed', [
'url' => $url,
]);
// If the test failed, we assume Page speed is not enabled
return false;
}

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.

Steps to Reproduce (for Bugs)

Context

Your Environment

  • Matomo Version: 4.13.0
  • PHP Version: 8.1
  • Server Operating System: Apache
  • Additionally installed plugins:
  • Browser:
  • Operating System:
@mattmary mattmary added Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. To Triage An issue awaiting triage by a Matomo core team member labels Dec 22, 2022
@sgiehl
Copy link
Member

sgiehl commented Dec 23, 2022

@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.

@sgiehl sgiehl removed the To Triage An issue awaiting triage by a Matomo core team member label Dec 23, 2022
@sgiehl sgiehl added this to the For Prioritization milestone Dec 23, 2022
@sgiehl sgiehl added Bug For errors / faults / flaws / inconsistencies etc. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Dec 23, 2022
@mattmary
Copy link
Contributor Author

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

@sgiehl
Copy link
Member

sgiehl commented Jan 12, 2023

@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),
    ]),
];

@mattmary
Copy link
Contributor Author

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?)

@tsteur
Copy link
Member

tsteur commented Jan 12, 2023

Yes, you can disable it there as well. Either same way as @sgiehl mentioned or similarly to the existing logic.

@sgiehl sgiehl added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label May 16, 2023
@sgiehl sgiehl removed this from the For Prioritization milestone May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants