matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.71k stars 2.62k forks source link

Scheduled task "checkSiteHasTrackedVisits" fails with exception User doesn't exist #19907

Open tsteur opened 1 year ago

tsteur commented 1 year ago

see below stack trace

ERROR [2022-10-24 02:05:15] 2060 Uncaught exception in API: Exception: User 'MyUsername' doesn't exist. in plugins/UsersManager/API.php:1303 Stack trace:

0 plugins/UsersManager/API.php(677): Piwik\Plugins\UsersManager\API->checkUserExists('MyUsername')

1 [internal function]: Piwik\Plugins\UsersManager\API->getUser('MyUsername')

2 core/API/Proxy.php(244): call_user_func_array(Array, Array)

3 core/Context.php(28): Piwik\API\Proxy->Piwik\API{closure}()

4 core/API/Proxy.php(335): Piwik\Context::executeWithQueryParameters(Array, Object(Closure))

5 core/API/Request.php(267): Piwik\API\Proxy->call('\Piwik\Plugins\...', 'getUser', Array)

6 core/API/Request.php(560): Piwik\API\Request->process()

7 plugins/CoreAdminHome/Tasks.php(165): Piwik\API\Request::processRequest('UsersManager.ge...', Array)

8 [internal function]: Piwik\Plugins\CoreAdminHome\Tasks->checkSiteHasTrackedVisits('3')

9 core/Scheduler/Scheduler.php(309): call_user_func(Array, '3')

10 core/Scheduler/Scheduler.php(154): Piwik\Scheduler\Scheduler->executeTask(Object(Piwik\Scheduler\Task))

11 plugins/CoreAdminHome/API.php(75): Piwik\Scheduler\Scheduler->run()

12 core/CronArchive.php(653): Piwik\Plugins\CoreAdminHome\API->runScheduledTasks()

13 core/CronArchive.php(279): Piwik\CronArchive->runScheduledTasks()

14 core/Access.php(661): Piwik\CronArchive->Piwik{closure}()

15 core/CronArchive.php(284): Piwik\Access::doAsSuperUser(Object(Closure))

16 plugins/CoreConsole/Commands/CoreArchiver.php(32): Piwik\CronArchive->main()

17 vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Piwik\Plugins\CoreConsole\Commands\CoreArchiver->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

18 vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

19 vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Piwik\Plugins\CoreConsole\Commands\CoreArchiver), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

20 [internal function]: Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

21 core/Console.php(135): call_user_func(Array, Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

22 core/Access.php(670): Piwik\Console->Piwik{closure}()

23 core/Console.php(136): Piwik\Access::doAsSuperUser(Object(Closure))

24 core/Console.php(87): Piwik\Console->doRunImpl(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

25 vendor/symfony/console/Symfony/Component/Console/Application.php(126): Piwik\Console->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

26 console(32): Symfony\Component\Console\Application->run()

27 {main}

ERROR [2022-10-24 02:05:15] 2060 Scheduler: Error User 'MyUsername' doesn't exist. for task 'Piwik\Plugins\CoreAdminHome\Tasks.checkSiteHasTrackedVisits_3'

Expected:

Error is caught in https://github.com/matomo-org/matomo/blob/4.12.2/plugins/CoreAdminHome/Tasks.php#L164-L169 as we would otherwise just return anyway if email not found

bx80 commented 1 year ago

Thanks @tsteur, so just to clarify - the checkSiteHasTrackedVisits scheduled task is trying to find the user who created the site, but if that user no longer exists, instead of throwing an exception, we should simply abort the task and return :+1:

I've scheduled this for prioritization.

tsteur commented 1 year ago

This happened again twice today.

tsteur commented 1 year ago

This problem happened again.

tsteur commented 10 months ago

This happened again