Way to process data using cron with disabled shell_exec with Piwik 2.1?

Hello
I was using cron to process statistic every half hour in P. 2.0.3 and earlier.
Everything was working smooth until I upgraded Piwik to 2.1 and got a cron notice that I can’t process the data because of disabled shell_exec.


PHP Warning:  shell_exec() has been disabled for security reasons in
/piwik/core/CliMulti/Process.php on line 165

Is there any way to process the data using cron in old manner (version < 2.1) or any other solution which do not rely on shell_exec ?
Reverting back to process stats upon login is not the best solution for me.

Thanks for the report I fixed it in Fixes #4824 Use HTTP API instead of async CLI when shell_exec is disa… · matomo-org/matomo@360ca40 · GitHub
and fixed a typo in: Fixes #4824 fix typo · matomo-org/matomo@68d0bdb · GitHub

if you can test the diff and confirm, cheers!

Thanks for lightning fast reply :slight_smile:
I checked the differences , and updated mentioned files.
But changes were still basing on shell_exec() function, which (along with exec()) isn’t enabled (I’ve seen that webhosts started to disable it for security reasons) on many shared hosting services, thus I knew I’ll get same error on my webhosting account.
This time on line 176:


PHP Warning:  shell_exec() has been disabled for security reasons in
/public_html/piwik/core/CliMulti/Process.php on line 176

So I assume that with P.2.1 the only way in this case is to process data only upon login.

btw. isn’t there an inconsistency in links to posted changes in files, because the process.php file contains:
$command = ‘pcntl_signal_dispatch’;
while other fix has this line replaced with $command = ‘shell_exec’; ?

replace your whole Process.php file by this: https://raw.github.com/piwik/piwik/720639c919024eceed9d64e9a57d9c9ada6eda43/core/CliMulti/Process.php

then hopefully it will work

It’s still breaking on blanks

why don’t use


preg_split ('/[,\s]+/', ini_get('disable_functions'));

instead of


explode(',', ini_get('disable_functions'));

what do you mean it’s breaking on blanks?

In the function


private static function shellExecFunctionIsDisabled()
    {
        $command = 'shell_exec';
        $disabled = explode(',', ini_get('disable_functions'));
        return in_array($command, $disabled);
    }

ini_get(‘disable_functions’) returns a string in the form of “show_source, system, shell_exec, popen, proc_open”

if you explode this you get


Array
(
    [0] => "show_source"
    [1] => " system"
    [2] => " shell_exec"
    [3] => " popen"
    [4] => " proc_open"
)

and “shell_exec” didn’t match to " shell_exec" with in_array

Thanks for the report! fixed in: Remove spaces in the list of disabled functions · matomo-org/matomo@7143784 · GitHub