Global 2FA prevents cron task to finish


(kartolo) #1

Activating 2FA for everyone prevents archive crontask to finish completely.

matomo-2fa

The error message is:

ERROR [2019-01-23 09:35:02] 12244  Empty or invalid response '' for website id 1, Time elapsed: 0.635s, skipping
ERROR [2019-01-23 09:35:03] 12244  Got invalid response from API request: ?module=API&method=API.get&idSite=4&period=day&date=last3&format=php&trigger=archivephp. Response was '<!DOCTYPE html> <html id="ng-app"  ng-app="piwikApp">     <head>                         <meta charset="utf-8">             <title>Anmelden - Matomo</title>             <meta http-equiv="X-UA-Compatible" content="IE=EDGE,chrome=1"/>             <meta name="viewport" content="initial-scale=1.0"/>             <meta name="generator" content="Matomo - free/libre analytics platform"/>             <meta name="description" content="Quelloffene Webanalytik"/>             <meta name="apple-itunes-app" content="app-id=737216887" />             <meta name="google" content="notranslate">                 <meta name="robots" content="index,follow">                  <link rel="shortcut icon" href="plugins/CoreHome/images/favicon.png"/>     <link rel="icon" type='image/png' sizes='256x256' href="plugins/CoreHome/images/applog
 o_256.png"/>              <link rel="mask-icon" href="plugins/CoreHome/images/applePinnedTab.svg" color="#3450A3">             <meta name="theme-color" 

(Lukas Winkler) #2

Hi,

I can reproduce this issue.

Can you please try out this fix and see if it solves the issue?

--- a/plugins/TwoFactorAuth/Validator.php
+++ b/plugins/TwoFactorAuth/Validator.php
@@ -8,6 +8,7 @@
 
 namespace Piwik\Plugins\TwoFactorAuth;
 
+use Piwik\Common;
 use Piwik\Piwik;
 use Piwik\Session\SessionFingerprint;
 use Exception;
@@ -27,6 +28,11 @@ public function __construct(TwoFactorAuthentication $twoFactorAuthentication)
 
     public function canUseTwoFa()
     {
+        if (Common::isPhpCliMode() && (!defined('PIWIK_TEST_MODE') || !PIWIK_TEST_MODE)) {
+            // eg when archiving or executing other commands
+            return false;
+        }
+
         if (!SettingsPiwik::isPiwikInstalled()) {
             return false;
         }


(kartolo) #3

some how I get memory_limit error. PHP memory_limit was 128M. I set this to 256M but still fatal error memory_limit.


(Fabian Dellwing) #4

What’s the exact error message?


(kartolo) #5

white screen with HTTP 500. in Apache log I found memory_limit error. 128 M memory limit was set. I double this to 256M and it still shows white screen (HTTP 500) and memory_limit error in log file


(kartolo) #6

in the github I see additional “use Piwik\Common;” is added. It works now


(Lukas Winkler) #7

Sorry,
I seem to have copied over only half of the patch.