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

[Bug]: $time must not be accessed before initialization #35543

Closed
6 of 9 tasks
pgaufillet opened this issue Dec 1, 2022 · 33 comments · Fixed by nextcloud/files_antivirus#254
Closed
6 of 9 tasks

[Bug]: $time must not be accessed before initialization #35543

pgaufillet opened this issue Dec 1, 2022 · 33 comments · Fixed by nextcloud/files_antivirus#254
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug

Comments

@pgaufillet
Copy link

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

Since the upgrade to NC 25, the following error pops up during the execution of cron jobs only at 02:00 and 14:00:

Error: Typed property OCP\BackgroundJob\Job::$time must not be accessed before initialization in /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php:102
Stack trace:
#0 /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php(93): OCP\BackgroundJob\TimedJob->start()
#1 /var/www/nextcloud/cron.php(152): OCP\BackgroundJob\TimedJob->execute()
#2 {main}

Steps to reproduce

  1. Just have a look to NC journal after 02:00/14:00 cron jobs execution.

Expected behavior

No error ;-)

Installation method

Community Web installer on a VPS or web space

Operating system

Debian/Ubuntu

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated to a major version (ex. 22.2.3 to 23.0.1)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

php occ config:list system
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "check_for_working_wellknown_setup": false,
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "25.0.1.1",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "default_language": "fr",
        "default_locale": "fr_FR",
        "installed": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "maintenance": false,
        "overwritehost": "***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https",
        "overwritewebroot": "***REMOVED SENSITIVE VALUE***",
        "overwritecondaddr": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 2,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "updater.release.channel": "stable",
        "mysql.utf8mb4": true,
        "default_phone_region": "FR",
        "trashbin_retention_obligation": "60,60"
    }
}

List of activated Apps

occ app:list
Enabled:
  - activity: 2.17.0
  - admin_audit: 1.15.0
  - calendar: 4.1.0
  - circles: 25.0.0
  - cloud_federation_api: 1.8.0
  - comments: 1.15.0
  - contacts: 5.0.1
  - dav: 1.24.0
  - drawio: 1.0.5
  - federatedfilesharing: 1.15.0
  - federation: 1.15.0
  - files: 1.20.1
  - files_antivirus: 4.0.0
  - files_external: 1.17.0
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - files_versions: 1.18.0
  - firstrunwizard: 2.14.0
  - groupfolders: 13.1.0
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - mail: 2.1.4
  - nextcloud_announcements: 1.14.0
  - notifications: 2.13.1
  - oauth2: 1.13.0
  - password_policy: 1.15.0
  - photos: 2.0.0
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - recommendations: 1.4.0
  - related_resources: 1.0.3
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - sharebymail: 1.15.0
  - support: 1.8.0
  - survey_client: 1.13.0
  - systemtags: 1.15.0
  - tasks: 0.14.5
  - text: 3.6.0
  - theming: 2.0.1
  - twofactor_backupcodes: 1.14.0
  - updatenotification: 1.15.0
  - viewer: 1.9.0
  - workflowengine: 2.7.0
Disabled:
  - bruteforcesettings
  - cms_pico: 1.0.21
  - contactsinteraction: 1.5.0
  - dashboard: 7.0.0
  - encryption
  - suspicious_login
  - twofactor_totp
  - user_external: 3.0.0
  - user_ldap
  - user_status: 1.0.1
  - weather_status: 1.0.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"SztDoEXmh8SzATpc1HMk","level":3,"time":"2022-12-01T13:00:03+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"/nextcloud/cron.php","message":"Typed property OCP\\BackgroundJob\\Job::$time must not be accessed before initialization","userAgent":"--","version":"25.0.1.1","exception":{"Exception":"Error","Message":"Typed property OCP\\BackgroundJob\\Job::$time must not be accessed before initialization","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":93,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","Line":102,"CustomMessage":"--"}}

Additional info

No response

@pgaufillet pgaufillet added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Dec 1, 2022
@szaimen
Copy link
Contributor

szaimen commented Dec 1, 2022

cc @come-nc

@petr-zeman
Copy link

I can confirm this bug.
Debian 11.5, PHP 8.1.12, fresh installation of NC 25.0.1

@flatterrich
Copy link

I can confirm this bug.
Debian 11.5, PHP 8.0.25, NC 25.0.1

@tech-nickel
Copy link

Can confirm this bug.
docker image nextcloud:25.0.1-apache

@rinal13
Copy link

rinal13 commented Dec 4, 2022

Same here @
Debian 11, PHP 8.1.13, NC 25.0.1

@Bad-and-Mad
Copy link

same here...
ArchLinux 5.15.81-1-lts, PHP 7.4.33, NC 25.0.1, Apache/2.4.54

@Buri
Copy link

Buri commented Dec 5, 2022

Same on docker nextcloud:latest

@come-nc
Copy link
Contributor

come-nc commented Dec 5, 2022

This looks like a subclass of TimedJob that bypasses the constructor. So far I only found this with the TimedJob from OC, but your trace shows it comes from the TimedJob of OCP.

Could one of you give the result of "occ background-job:list --limit=100" ?

@flatterrich
Copy link

result of "occ background-job:list --limit=100"
abfrage.txt

@come-nc
Copy link
Contributor

come-nc commented Dec 5, 2022

Thank you.
Problem seems to be OCA/Files_Antivirus/BackgroundJob/BackgroundScanner.
Can the other confirm you all have the files_antivirus application enabled?

@come-nc
Copy link
Contributor

come-nc commented Dec 5, 2022

And it is my fault 😭 nextcloud/files_antivirus@ba33506

@Bad-and-Mad
Copy link

I have the files_antivirus application enabled.

@come-nc
Copy link
Contributor

come-nc commented Dec 5, 2022

Can someone confirm that this fixes the problem: https://patch-diff.githubusercontent.com/raw/nextcloud/files_antivirus/pull/254.diff ?
(applied in files_antivirus folder)

@pgaufillet
Copy link
Author

Patch applied. Next invocation of the faulty piece of code scheduled at 14:00. Is there a mean to force the execution?

@flatterrich
Copy link

Patch applied

@Steve8291
Copy link

Thanks for the patch. I've applied it as well and next run will be 15:11

@pgaufillet
Copy link
Author

No more error in the journal. Thanks 👍

@Bad-and-Mad
Copy link

Also from my side, the problem seems to be fixed.
Thanks!

@pgaufillet
Copy link
Author

pgaufillet commented Dec 7, 2022

Thank you @come-nc for the quick fix and release of files_antivirus 4.0.1 😊
I have faced some issues during the upgrade (inconsistent app signature), but I guess it is linked to the patch and not to the new release as it has disappeared.

@rkrenzin
Copy link

Great, thanks that someone fixed the bug.But I am not a computer specialist, so I don't know how to apply or to type in the code given in the patch link.

Can someone explain? Thanks a lot.

@Steve8291
Copy link

@rkrenzin I'm pretty sure the commit has been pushed out. You can just update your Antivirus for Files app through the Nextcloud browser interface like you normally do for any other update.

@ghost
Copy link

ghost commented Dec 10, 2022

Great, thanks that someone fixed the bug.But I am not a computer specialist, so I don't know how to apply or to type in the code given in the patch link.

Can someone explain? Thanks a lot.

No need, should be included in the 4.0.1 release (which isn't on github's release page but it is via Nextcloud apps management).
(Ah, Steve8291 beat me to it)

Otherwise (for the sake of learning), https://patch-diff.githubusercontent.com/raw/nextcloud/files_antivirus/pull/254.diff (the patch supplied on December 5 by come-nc) shows the differences between the old /lib/BackgroundJob/BackgroundScanner.php file and the new one, as seen on top of that page:

diff --git [[a/lib/BackgroundJob/BackgroundScanner.php]] [[b/lib/BackgroundJob/BackgroundScanner.php]]
index 3023736..7f35447 100644
--- [[a/lib/BackgroundJob/BackgroundScanner.php]]
+++ [[b/lib/BackgroundJob/BackgroundScanner.php]]

Since that path is relative to the application's path, the full path to that file would be (ROOT_OF_NEXTCLOUD)/apps/files_antivirus/lib/BackgroundJob/BackgroundScanner.php

As for how diff works: https://en.wikipedia.org/wiki/Diff
You then could apply those shared changes in your own installation (which is, once again, no longer needed)

@rkrenzin
Copy link

@Steve8291 Many thanks for the quick replay. I've just updated antivirus and will see if the error message will not appear again.

@Kwarde666 I appreciate your additional explanations. Many thanks. Learning is always good :-)

@rkrenzin
Copy link

@Kwarde666 Is all the code just one command to be copied in the command line of the terminal window?

@ghost
Copy link

ghost commented Dec 10, 2022

@rkrenzin No.
See that Wikipedia link.
Contents of the patch shows the differences between the old file (your local file) and the new file (the patch).
You'd thus either ...
1- have to open that file using an editor (something as simple as notepad or nano would even suffice) and apply the changes as shown.
2- Use the command diff (Unix/Linux) or FC (Windows, apparently).
See:
https://www.pair.com/support/kb/paircloud-diff-and-patch/
https://stackoverflow.com/questions/6877238/what-is-the-windows-equivalent-of-the-diff-command

@Monoboy4ik
Copy link

Monoboy4ik commented Feb 26, 2024

hello!
NC 28.0.2 , docker
See this:

2024-02-23T02:20:01.418631023Z Error: Typed property OCP\BackgroundJob\Job::$time must not be accessed before initialization in /var/www/html/lib/public/BackgroundJob/TimedJob.php:101
2024-02-23T02:20:01.418765394Z Stack trace:
2024-02-23T02:20:01.418864825Z #0 /var/www/html/lib/public/BackgroundJob/TimedJob.php(92): OCP\BackgroundJob\TimedJob->start(Object(OC\BackgroundJob\JobList))
2024-02-23T02:20:01.418910536Z #1 /var/www/html/cron.php(152): OCP\BackgroundJob\TimedJob->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log))
2024-02-23T02:20:01.418940606Z #2 {main}

result of “occ background-job:list --limit=100” :

joblist.txt

@come-nc
Copy link
Contributor

come-nc commented Feb 26, 2024

hello! NC 28.0.2 , docker See this:

2024-02-23T02:20:01.418631023Z Error: Typed property OCP\BackgroundJob\Job::$time must not be accessed before initialization in /var/www/html/lib/public/BackgroundJob/TimedJob.php:101 2024-02-23T02:20:01.418765394Z Stack trace: 2024-02-23T02:20:01.418864825Z #0 /var/www/html/lib/public/BackgroundJob/TimedJob.php(92): OCP\BackgroundJob\TimedJob->start(Object(OC\BackgroundJob\JobList)) 2024-02-23T02:20:01.418910536Z #1 /var/www/html/cron.php(152): OCP\BackgroundJob\TimedJob->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log)) 2024-02-23T02:20:01.418940606Z #2 {main}

result of “occ background-job:list --limit=100” :

joblist.txt

See eldertek/duplicatefinder#57
Disable duplicatefinder application or wait for a fix from them.

@Monoboy4ik
Copy link

hello! NC 28.0.2 , docker See this:
2024-02-23T02:20:01.418631023Z Error: Typed property OCP\BackgroundJob\Job::$time must not be accessed before initialization in /var/www/html/lib/public/BackgroundJob/TimedJob.php:101 2024-02-23T02:20:01.418765394Z Stack trace: 2024-02-23T02:20:01.418864825Z #0 /var/www/html/lib/public/BackgroundJob/TimedJob.php(92): OCP\BackgroundJob\TimedJob->start(Object(OC\BackgroundJob\JobList)) 2024-02-23T02:20:01.418910536Z #1 /var/www/html/cron.php(152): OCP\BackgroundJob\TimedJob->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log)) 2024-02-23T02:20:01.418940606Z #2 {main}
result of “occ background-job:list --limit=100” :
joblist.txt

See eldertek/duplicatefinder#57 Disable duplicatefinder application or wait for a fix from them.

Thanks a lot!

@piojan
Copy link

piojan commented Mar 8, 2024

For consideration - perhaps error handling for BackgroundJob could be improve to point out in a more obvious way which job is causing issues. (without the need to use the occ command).

@vgrosdoy
Copy link

same error for me -- nextcloud 28.0.4
application : cron
Error Typed property OCP\BackgroundJob\Job::$time must not be accessed before initialization
Exception thrown: Error

do not know hopw to apply the patch provided by @come-nc (#35543 (comment))

Thanks a lot for your help

@Steve8291
Copy link

@vgrosdoy
I'm on the same version and not seeing the error in my logs. I wonder if something else is misconifgured. You should not need to apply the patch.

@come-nc
Copy link
Contributor

come-nc commented Apr 29, 2024

@vgrosdoy No patching is needed this patch was released already.
Most likely your error comes from another application, try getting a trace to see which job is causing the problem.

@vgrosdoy
Copy link

it seems the issue was due to DuplicateFinder addons
Thanks to all for your answers
have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.