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

CronArchive: Warning, Invalid argument supplied for foreach regression #4866

Closed
anonymous-matomo-user opened this issue Mar 17, 2014 · 6 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

I run multiple large websites so i use crontab to do cron jobs, it stopped working after i updated to 2.1.0 trough the web interface.

I get the following on multiple instances on piwik i use after accessing https://stats.mywebsite.com/misc/cron/archive.php?token_auth=mykeyhere

See attached
Keywords: cron

@anonymous-matomo-user
Copy link
Author

I could not attach file, so i used pastebin http://pastebin.com/MVFd7Gis

@hpvd
Copy link

hpvd commented Mar 17, 2014

maybe this is related to
to #4780
?

@anonymous-matomo-user
Copy link
Author

Replying to hpvd:

maybe this is related to
to #4780
?

I read that one before i wrote this one, i don't think that one relates as it has to do with timing, in this case it wont process at all. But who knows

@anonymous-matomo-user
Copy link
Author

Pretty sure the issue is with the cleanupNotRemovedFiles() function calling a foreach loop on the variable $files. There needs to be a check if $files is empty before calling the foreach loop, as shown below. This fixed the error for me:

public static function cleanupNotRemovedFiles()
{
    $timeOneWeekAgo = strtotime('-1 week');
    $files = _glob(self::getTmpPath() . '/*');
    if(empty($files)) {
       return;
    }
    foreach ($files as $file) {
        $timeLastModified = filemtime($file);

        if ($timeOneWeekAgo > $timeLastModified) {
            unlink($file);
        }
    }
}

@mattab
Copy link
Member

mattab commented Mar 21, 2014

Thanks for the report! fixed and available in latest beta

4ec3413

@mattab
Copy link
Member

mattab commented Apr 1, 2014

In 99ff035: Fixes #4866 @ldrrp Can you please try this patch and confirm it fixes the issue for you?

This issue was closed.
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.
Projects
None yet
Development

No branches or pull requests

3 participants