marius-wieschollek / passwords

A simple, yet feature rich password manager for Nextcloud
GNU Affero General Public License v3.0
215 stars 46 forks source link

[BUG]: Cron doesn't seem to be working lately #644

Open bugbountyguy opened 8 months ago

bugbountyguy commented 8 months ago

⚠️ This issue respects the following points: ⚠️

Server Information

{
    "version": {
        "server": "28.0.3.2",
        "app": "2024.3.20",
        "lsr": false,
        "php": "8.2.16",
        "cronPhp": "8.2.16"
    },
    "environment": {
        "os": "Linux",
        "architecture": "x86_64",
        "bits": 64,
        "database": "mysql",
        "cron": "cron",
        "proxy": false,
        "sslProxy": false,
        "subdirectory": false
    },
    "services": {
        "images": "imagick",
        "favicons": "default",
        "previews": "default",
        "security": "hibp",
        "words": "auto",
        "previewApi": false,
        "faviconApi": false
    },
    "status": {
        "autoBackupRestored": false
    },
    "settings": {
        "channel": "stable",
        "nightlies": true,
        "handbook": false,
        "performance": 5
    },
    "encryption": {
        "sse": {
            "SSEv1r1": false,
            "SSEv1r2": true,
            "SSEv2r1": false,
            "SSEv3r1": false,
            "none": true,
            "default": "none"
        },
        "cse": {
            "CSEv1r1": true,
            "none": true,
            "default": "CSEv1r1"
        }
    }
}

Client Information

N/A (server side issue)

Bug description

I saw the other bug report, but was unable to reply to it. The mention was of the reporter having an old version of PHP - however, my PHP is up to date on both the app and cron, so I don't think that's related? I've got the latest nextcloud:apache images that are available.

I'm getting an exception in the nextcloud logs, which is resulting in cron failing and cascading to the other cron jobs:

Mar  6 09:15:01 127.0.0.1 nextcloud: {"reqId":"[[FILTERED]]","level":3,"time":"2024-03-06T15:15:00+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Exception thrown: ArgumentCountError","userAgent":"--","version":"28.0.3.2","exception":{"Exception":"ArgumentCountError","Message":"Too few arguments to function OCA\\Passwords\\Cron\\CheckPasswordsJob::__construct(), 0 passed in /var/www/html/lib/private/BackgroundJob/JobList.php on line 330 and exactly 9 expected","Code":0,"Trace":[{"file":"/var/www/html/lib/private/BackgroundJob/JobList.php","line":330,"function":"__construct","class":"OCA\\Passwords\\Cron\\CheckPasswordsJob","type":"->","args":[]},{"file":"/var/www/html/lib/private/BackgroundJob/JobList.php","line":235,"function":"buildJob","class":"OC\\BackgroundJob\\JobList","type":"->","args":[[69928,"OCA\\Passwords\\Cron\\CheckPasswordsJob","null",0,1709625704,0,38,"[[FILTERED]]",0]]},{"file":"/var/www/html/cron.php","line":145,"function":"getNext","class":"OC\\BackgroundJob\\JobList","type":"->","args":[false]}],"File":"/var/www/html/custom_apps/passwords/lib/Cron/CheckPasswordsJob.php","Line":58,"CustomMessage":"Exception thrown: ArgumentCountError"}} 

Steps to reproduce

I guess update to the latest version of passwords and nextcloud and you'll have this happen

Expected behavior

Cron works

Nextcloud Logs

See above

Browser Logs

No response

marius-wieschollek commented 8 months ago

This seems like the same error message.

Have you tried runnin the cron.php file manually and see if the issue disappears?

bugbountyguy commented 8 months ago

This is kinda weird. I put a try/catch statement around the line that was erroring out so that the rest of the crons would be able to run instead of just dying early. I went and removed that now and then tried to run it manually, no error. I kept that try and catch commented out, and no more errors are showing up in the logs. Perhaps there's a job that doesn't happen as frequently and the flooded errors were due to constant retries or something? Lemme get back to you later to see if it shows up again and I'll try the manual run of cron.php again (within 24 hours) to see what happens.

marius-wieschollek commented 8 months ago

The check passwords job is supposed to run once a day.

dboehmer commented 3 months ago

I have the same issue and posted a bug report accidentally to the wrong GitHub project as https://github.com/nextcloud/password_policy/issues/628

My workaround was to disable the Passwords app in Nextcloud. This made the cronjob run successfully again but is obviously no real solution. I just enabled it again for testing and it’s still broken.

Tiller commented 3 months ago

Hi, I've had the same issue today after installing Passwords on my 29.0.5 instance. However, I did figure out the issue : my cron was setup in my www-data's crontab as follow:

*/5 * * * * php8.1 -f /var/www/nextcloud/cron.php

As I upgraded to php 8.2 some time ago, it should have been updated to :

*/5 * * * * php8.2 -f /var/www/nextcloud/cron.php

This fixed the issue. So I believe the latest version of Passwords is incompatible with php 8.1.

$  sudo -u www-data php8.1 -f /var/www/nextcloud/cron.php 
ArgumentCountError: Too few arguments to function OCA\Passwords\Cron\SynchronizeShares::__construct(), 0 passed in /var/www/nextcloud/lib/private/BackgroundJob/JobList.php on line 330 and exactly 9 expected in /var/www/nextcloud/apps/passwords/lib/Cron/SynchronizeShares.php:58
Stack trace:
#0 /var/www/nextcloud/lib/private/BackgroundJob/JobList.php(330): OCA\Passwords\Cron\SynchronizeShares->__construct()
#1 /var/www/nextcloud/lib/private/BackgroundJob/JobList.php(235): OC\BackgroundJob\JobList->buildJob()
#2 /var/www/nextcloud/cron.php(163): OC\BackgroundJob\JobList->getNext()
#3 {main}

$  sudo -u www-data php8.2 -f /var/www/nextcloud/cron.php
<OK>
dboehmer commented 3 months ago

Unfortunately the PHP version for the cronjob is already set to 8.2 in the settings at my shared web space provider.

dboehmer commented 3 months ago

Update: Inspired by the report above I set the PHP version for the cronjob to 8.3 and that seems to have solved the issue. I get no more hourly error reports from Nextcloud and the status page doesn’t indicate the cronjob had not run. :tada: