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

PHP Fatal error: Uncaught Error: Call to undefined function Piwik\CliMulti\getmypid() #660

Closed mpoideg closed 11 months ago

mpoideg commented 1 year ago

Hi! Archiving doesn't work on hosting because of security reason (getmypid won't be allowed...). I found a solved issue, where there was a bugfix if pid was not possible to get. (2019)

Should this work already? Or how can I call archiving cron (like I do it from backend-button right now) by myself with manipulating (Is the pid nessesary for the valid statistics data?) the pid as parameter?

Thanks a lot! Marco

mattmary commented 1 year ago

Hello @mpoideg

Unfortunately, getmypid is a Matomo requirement. May I ask you which is your hosting provider?

@tsteur, any workaround in mind? I can see that in some parts of the Matomo code we check if getmypid is available. It looks like this is not the case in this file. Do you want me to create an issue in the matomo repository?

Kind regards

Mat

tsteur commented 1 year ago

We did some work in https://github.com/matomo-org/matomo/pull/16936 because of https://wordpress.org/support/topic/warning-getmypid-has-been-disabled/ when getmypid isn't available. Archiving should then still work but use HTTP as a fallback instead of the CLI command.

As far as I know you're not supposed to get such an error when getmypid isn't available.

mattmary commented 1 year ago

As far as I can see, this call is made here: https://github.com/matomo-org/matomo/blob/e4f9a638e600ada201739f17319512a32a3120a0/core/CliMulti.php#L362

And this method is only called here: https://github.com/matomo-org/matomo/blob/e4f9a638e600ada201739f17319512a32a3120a0/core/CliMulti.php#L185

Not sure when is called this method in the plugin. Is it a WordPress only case?

mpoideg commented 1 year ago

@mattmary: It's raidboxes - fastest wordpress-provider located here in Germany...

mattmary commented 1 year ago

@mattab I added it to the backlog. But we may consider this is a regression as we previously work on this subject and this case is not covered. Let you choose.

mattmary commented 1 year ago

@mpoideg

Thank you. Would you mind posting your system report available from the "Matomo Analytics > Diagnostics" menu? How do you run your WordPress crontab? With the wp-cron script? Is it called from the command line or from the browser, do you know? Do you have the same error when running the archiving process from the "Matomo Analytics > Diagnostics > Troubleshooting" menu? Kind regards

Mat

mpoideg commented 1 year ago

Thx Mat!

System report:

              # Matomo

Endpoints

Crons

Vorgeschriebene Prüfungen

Optionale Prüfungen

Matomo Settings

Logs

WordPress

WordPress Plugins

MU Plugins

Plugins

Server

Database

Browser

Crons are running every minute from server side... I think from command line - but not sure...

When I run the process from Troubleshooting-Menu it works, but I'm landing on a source-code view site. But: It works and archiving is done...

Kind regards, Marco

mattmary commented 1 year ago

Hello @mpoideg

Thank you. After running the archiving process from the Troubleshooting menu, and if you land on a source-code view, it means there is an error. Maybe you could email us the content of this page (wordpress@matomo.org) ? But glad to see that your archiving allow you to get data anyway.

Kind regards

Mat

mpoideg commented 1 year ago

Mail sent!

mattmary commented 1 year ago

Thank you, @mpoideg

https://secure.helpscout.net/conversation/2055479128/2999402?folderId=4753515 Looks like you don't have any error when running the archiving process manually. Good to hear.

We have scheduled this issue in the next sprint, but it may take some time to be solved. Alternatively, you could try to add in your wp-config.php the following content: if (!defined('MATOMO_SUPPORT_ASYNC_ARCHIVING')) { define('MATOMO_SUPPORT_ASYNC_ARCHIVING', false); } Then your archiving process won't be run any more from the WordPress cron task (which seems to lead to your error), but when directly when rendering the Matomo page. Let me know if it works.

Kind regards

Mat

mattmary commented 1 year ago

Hello @mpoideg

Did this approach solve your issue?

Kind regards

Mat

mpoideg commented 1 year ago

Hi @mattmary!

Thanks for asking, but unfortunately it's not the solution. Same as before.

Kind regards, Marco

mattmary commented 1 year ago

Hello @mpoideg

I've seen that you use PHP 8.1. Do you also have the problem like in this issue? https://github.com/matomo-org/matomo-for-wordpress/issues/676

mattmary commented 1 year ago

Hello @mpoideg

Do you still encounter this issue with the latest plugin release? Have you been able to solve your problem? Kind regards

Mat

Dominic-Marcelino commented 1 year ago

Hi there, having the same issue on Raidboxes. Matomo-Plugin-Version: 4.14.1 Archiving manually via button on the Troubleshooting site works.

Supports Async Archiving is automatically detected as no.

[29-Mar-2023 10:30:58 UTC] PHP Fatal error: Uncaught Error: Call to undefined function Piwik\CliMulti\getmypid() in /home/wp/disk/wordpress/wp-content/plugins/matomo/app/core/CliMulti/Process.php:125
--
[29-Mar-2023 10:30:53 UTC] Matomo: Scheduled tasks archive data

Is there any solution / workaround?

Would define('MATOMO_SUPPORT_ASYNC_ARCHIVING', false); change anything even if it's auto-detected as false?

lance-matomo commented 1 year ago

Hey @tsteur I've been looking through the matomo code and it looks like those checks around if getmypid is disabled aren't being used when the startProcess function is called in matomo/app/core/CliMulti/Process.php:125 that I can see. This may be a regression as I can see an unused function in SharedSiteIds.php that checks if it is supported...

tsteur commented 1 year ago

@lance-matomo This looks like a bug indeed. If async is disabled, then it technically shouldn't even call this AFAIK

lance-matomo commented 1 year ago

I've created an issue on the main matomo repository for this: https://github.com/matomo-org/matomo/issues/20537

diosmosis commented 11 months ago

Fixed in core in Matomo 5 and worked around in the latest version of MWP.