Cron.php: Call to a member function getUserFolder() on null

Nextcloud version (eg, 12.0.2): 16.0.8
Operating system and version (eg, Ubuntu 17.04): NixOS 19.09
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.16.1
PHP version (eg, 7.1): 7.3.13

The issue you are facing:
According to web interface the cronjob is not running for a couple of hours.
Logs by systemd shows that it is started every 10 minutes but has errors (see below).
This started when I was still on 16.0.7, I then updated to 16.0.8 with no change.
From the timing I believe that the desktop client was syncing files when the error started. Synchronization has finished in the mean time. Apart from the cron issue, everything seems to be fine.

I want to fix this error, so the cron job is running again.

Feb 01 22:16:51 myserver systemd[1]: Starting nextcloud-cron.service...
Feb 01 22:16:51 myserver Nextcloud[3437]: {PHP} Undefined property: OCA\Maps\BackgroundJob\UpdatePhotoByFileJob::$root at /srv/xxx//store-apps/maps/lib/BackgroundJob/UpdatePhotoByFileJob.php#43
Feb 01 22:16:51 myserver Nextcloud[3437]: {cron} {"Exception":"Error","Message":"Call to a member function getUserFolder() on null","Code":0,"Trace":[{"file":"\/nix\/store\/65qfqw4wwda1vim59l22c7vmawi1dkdm-nextcloud-16.0.7\/lib\/public\/BackgroundJob\/Job.php","line":77,"function":"run","class":"OCA\\Maps\\BackgroundJob\\UpdatePhotoByFileJob","type":"->","args":[{"fileId":126863,"userId":"xxx"}]},{"file":"\/nix\/store\/65qfqw4wwda1vim59l22c7vmawi1dkdm-nextcloud-16.0.7\/lib\/public\/BackgroundJob\/QueuedJob.php","line":46,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]},{"file":"\/nix\/store\/65qfqw4wwda1vim59l22c7vmawi1dkdm-nextcloud-16.0.7\/cron.php","line":123,"function":"execute","class":"OCP\\BackgroundJob\\QueuedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"\/srv\/xxx\/store-apps\/maps\/lib\/BackgroundJob\/UpdatePhotoByFileJob.php","Line":43,"CustomMessage":"--"}
Feb 01 22:16:51 myserver systemd[1]: nextcloud-cron.service: Succeeded.
Feb 01 22:16:51 myserver systemd[1]: Started nextcloud-cron.service.
Feb 01 22:26:53 myserver systemd[1]: Starting nextcloud-cron.service...
Feb 01 22:26:53 myserver Nextcloud[5007]: {PHP} Undefined property: OCA\Maps\BackgroundJob\UpdatePhotoByFileJob::$root at /srv/xxx//store-apps/maps/lib/BackgroundJob/UpdatePhotoByFileJob.php#43
Feb 01 22:26:53 myserver Nextcloud[5007]: {cron} {"Exception":"Error","Message":"Call to a member function getUserFolder() on null","Code":0,"Trace":[{"file":"\/nix\/store\/3dvvw2zsazdh0y9rby01aibpjdz2adfj-nextcloud-16.0.8\/lib\/public\/BackgroundJob\/Job.php","line":77,"function":"run","class":"OCA\\Maps\\BackgroundJob\\UpdatePhotoByFileJob","type":"->","args":[{"fileId":126864,"userId":"xxx"}]},{"file":"\/nix\/store\/3dvvw2zsazdh0y9rby01aibpjdz2adfj-nextcloud-16.0.8\/lib\/public\/BackgroundJob\/QueuedJob.php","line":46,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]},{"file":"\/nix\/store\/3dvvw2zsazdh0y9rby01aibpjdz2adfj-nextcloud-16.0.8\/cron.php","line":123,"function":"execute","class":"OCP\\BackgroundJob\\QueuedJob","type":"->","args":[{"__class__":"OC\\BackgroundJob\\JobList"},{"__class__":"OC\\Log"}]}],"File":"\/srv\/xxx\/store-apps\/maps\/lib\/BackgroundJob\/UpdatePhotoByFileJob.php","Line":43,"CustomMessage":"--"}
Feb 01 22:26:53 myserver systemd[1]: nextcloud-cron.service: Succeeded.
Feb 01 22:26:53 myserver systemd[1]: Started nextcloud-cron.service.

Is this the first time you’ve seen this error? (Y/N): Today is the first time, the error repeats on every cron run since a couple of hours.

Steps to replicate it:

  1. Unknown step
  2. Rerun the cron job.

The output of your Nextcloud log in Admin > Logging:

Log is empty, everything appears to be fine (translated from german)

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/srv/xxx/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/srv/xxx/store-apps',
      'url' => '/store-apps',
      'writable' => true,
    ),
  ),
  'datadirectory' => '/srv/xxx/data',
  'skeletondirectory' => '',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'log_type' => 'syslog',
  'log_level' => '2',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbuser' => 'nextcloud',
  'dbtype' => 'sqlite',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'version' => '16.0.8.1',
  'overwrite.cli.url' => 'http://localhost',
  'installed' => true,
  'instanceid' => 'xxx',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'pipe',
  'mail_from_address' => 'nextcloud',
  'mail_domain' => 'xxx',
  'trusted_domains' =>
  array (
    0 => 'xxx',
  ),
  'updater.secret' => 'xxx',
);

The output of your Apache/nginx/system log in /var/log/____:
I don’t think it’s relevant for cron, I’ll provide it if relevant.

I’m seeing the same issue with v17.0.3 - when I went to update from v17.0.2 I saw the warning but hoped may the update would resolve it, but it still happens. The log file shows:

[cron] Error: Error: Call to a member function getUserFolder() on null at <<closure>>

0. /var/www/html/nextcloud/lib/public/BackgroundJob/Job.php line 77
   OCA\Maps\BackgroundJob\UpdatePhotoByFileJob->run({fileId: 60679,userId: "ferd"})
1. /var/www/html/nextcloud/lib/public/BackgroundJob/QueuedJob.php line 46
   OCP\BackgroundJob\Job->execute(OC\BackgroundJob\JobList {}, OC\Log {})
2. /var/www/html/nextcloud/cron.php line 124
   OCP\BackgroundJob\QueuedJob->execute(OC\BackgroundJob\JobList {}, OC\Log {})

at 2020-02-02T12:35:01+00:00

I also see just before a log entry:

[PHP] Error: Undefined property: OCA\Maps\BackgroundJob\UpdatePhotoByFileJob::$root at /var/www/html/nextcloud/apps/maps/lib/BackgroundJob/UpdatePhotoByFileJob.php#43

at 2020-02-02T12:35:01+00:00

Did some digging, do you have the “Maps” app installed? It causes this issue at the moment, so just disabling will sort it - the next cron will run just a little longer than normal as it catches up.

A fix for Maps is in test and will be out soon.

4 Likes

Yes, I’ve got maps installed. Good to know that a fix is being tested, thanks!

Same problem as OP thanks for digging in, disabling for now.

1 Like

Same problem for me too, I think it broke when I updated to 17.0.3.
Disabling the Maps app solved the problem for me too.

2 Likes

I’ve disabled my maps app too, monitoring now.

The error no longer there after disabled maps.