nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.5k stars 4.08k forks source link

[Bug]: occ versions:expire doesn't work on NC 26 #37527

Closed enoch85 closed 10 months ago

enoch85 commented 1 year ago

⚠️ This issue respects the following points: ⚠️

Bug description

It was supposed to be fixed with this PR but it's still happening on a newly updated NC 26 instance.

Cron doesn't behave as it should.

cc @artonge

Steps to reproduce

  1. Run occ versions:expire -vvv
  2. Get a stack trace

Expected behavior

Everything should work.

Installation method

Community Manual installation with Archive

Nextcloud Server version

26

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

PostgreSQL

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?

Configuration report

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "192.168.1.64",
            "domain.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "26.0.0.11",
        "overwrite.cli.url": "https:\/\/domain.com\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "upgrade.disable-web": true,
        "log_type": "file",
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "loglevel": "2",
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "mail_smtpmode": "smtp",
        "remember_login_cookie_lifetime": "1800",
        "log_rotate_size": "10485760",
        "trashbin_retention_obligation": "auto, 60",
        "versions_retention_obligation": "auto, 180",
        "activity_expire_days": "120",
        "simpleSignUpLink.shown": false,
        "default_phone_region": "de",
        "logtimezone": "Europe\/Berlin",
        "htaccess.RewriteBase": "\/",
        "maintenance": false,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": true,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0.5,
            "dbindex": 0,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - activity: 2.18.0
  - admin_audit: 1.16.0
  - announcementcenter: 6.5.1
  - appointments: 1.14.13
  - bookmarks: 13.0.1
  - bruteforcesettings: 2.6.0
  - calendar: 4.3.1
  - circles: 26.0.0
  - cloud_federation_api: 1.9.0
  - collectives: 2.4.0
  - comments: 1.16.0
  - contacts: 5.2.0
  - contactsinteraction: 1.7.0
  - dashboard: 7.6.0
  - dav: 1.25.0
  - deck: 1.9.0
  - drawio: 2.1.0
  - external: 5.1.0
  - federatedfilesharing: 1.16.0
  - federation: 1.16.0
  - files: 1.21.1
  - files_accesscontrol: 1.16.0
  - files_automatedtagging: 1.16.1
  - files_downloadactivity: 1.16.0
  - files_pdfviewer: 2.7.0
  - files_rightclick: 1.5.0
  - files_sharing: 1.18.0
  - files_trashbin: 1.16.0
  - files_versions: 1.19.1
  - firstrunwizard: 2.15.0
  - forms: 3.2.0
  - groupfolders: 14.0.0
  - logreader: 2.11.0
  - lookup_server_connector: 1.14.0
  - mail: 3.0.2
  - maps: 1.0.2
  - nextcloud_announcements: 1.15.0
  - notes: 4.7.2
  - notifications: 2.14.0
  - notify_push: 0.6.2
  - oauth2: 1.14.0
  - password_policy: 1.16.0
  - passwords: 2023.3.21
  - photos: 2.2.0
  - polls: 4.1.8
  - privacy: 1.10.0
  - provisioning_api: 1.16.0
  - quota_warning: 1.16.0
  - recognize: 3.7.0
  - recommendations: 1.5.0
  - related_resources: 1.1.0-alpha1
  - richdocuments: 8.0.0
  - serverinfo: 1.16.0
  - settings: 1.8.0
  - sharebymail: 1.16.0
  - side_menu: 3.7.2
  - spreed: 16.0.2
  - support: 1.9.0
  - survey_client: 1.14.0
  - systemtags: 1.16.0
  - tasks: 0.14.5
  - text: 3.7.2
  - theming: 2.1.1
  - twofactor_backupcodes: 1.15.0
  - updatenotification: 1.16.0
  - user_ldap: 1.16.0
  - user_status: 1.6.0
  - viewer: 1.10.0
  - weather_status: 1.6.0
  - workflowengine: 2.8.0
Disabled:
  - emlviewer: 1.0.7 (installed 1.0.7)
  - encryption: 2.14.0
  - files_external: 1.18.0
  - files_linkeditor: 1.1.13 (installed 1.1.13)
  - files_mindmap: 0.0.27 (installed 0.0.27)
  - ransomware_protection: 1.14.0 (installed 1.14.0)
  - richdocumentscode: 22.5.802 (installed 22.5.802)
  - suspicious_login: 4.4.0 (installed 4.4.0)
  - twofactor_totp: 8.0.0-alpha.

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"lZv2M6sjWjTlp1uWCF4D","level":3,"time":"2023-03-31T22:55:13+02:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"Error while running background job (class: OCA\\Files_Versions\\BackgroundJob\\ExpireVersions, arguments: )","userAgent":"--","version":"26.0.0.11","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"/drseitner.admin/files/Personal/05 Personalakten/Besnik Karai/Zahntechniker.docx","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Node/Folder.php","line":139,"function":"get","class":"OC\\Files\\Node\\Root","type":"->"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":595,"function":"get","class":"OC\\Files\\Node\\Folder","type":"->"},{"function":"OCA\\Files_Versions\\{closure}","class":"OCA\\Files_Versions\\Storage","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":610,"function":"array_filter"},{"file":"/var/www/nextcloud/apps/files_versions/lib/BackgroundJob/ExpireVersions.php","line":69,"function":"expireOlderThanMaxForUser","class":"OCA\\Files_Versions\\Storage","type":"::"},{"file":"/var/www/nextcloud/lib/private/User/Manager.php","line":639,"function":"OCA\\Files_Versions\\BackgroundJob\\{closure}","class":"OCA\\Files_Versions\\BackgroundJob\\ExpireVersions","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/apps/files_versions/lib/BackgroundJob/ExpireVersions.php","line":70,"function":"callForSeenUsers","class":"OC\\User\\Manager","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":78,"function":"run","class":"OCA\\Files_Versions\\BackgroundJob\\ExpireVersions","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":103,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"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/private/Files/Node/Root.php","Line":209,"message":"Error while running background job (class: OCA\\Files_Versions\\BackgroundJob\\ExpireVersions, arguments: )","exception":{},"CustomMessage":"Error while running background job (class: OCA\\Files_Versions\\BackgroundJob\\ExpireVersions, arguments: )"}}
OCP\AppFramework\Db\DoesNotExistException: Did expect one result but found none when executing: query "SELECT * FROM `*PREFIX*files_versions` WHERE (`file_id` = :dcValue1) AND (`timestamp` = :dcValue2)";

    /var/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php - line 361:

    OCP\AppFramework\Db\QBMapper->findOneQuery()

    /var/www/nextcloud/apps/files_versions/lib/Db/VersionsMapper.php - line 78:

    OCP\AppFramework\Db\QBMapper->findEntity()

    /var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php - line 242:

    OCA\Files_Versions\Db\VersionsMapper->findVersionForFileId()

    /var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php - line 106:

    OCA\Files_Versions\Listener\FileEventsListener->post_write_hook()

    /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php - line 86:

    OCA\Files_Versions\Listener\FileEventsListener->handle()

    /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 251:

    OC\EventDispatcher\ServiceEventListener->__invoke()

    /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 73:

    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()

    /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php - line 87:

    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

    /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php - line 99:

    OC\EventDispatcher\EventDispatcher->dispatch()

    /var/www/nextcloud/lib/private/Files/Node/HookConnector.php - line 118:

    OC\EventDispatcher\EventDispatcher->dispatchTyped()

    /var/www/nextcloud/lib/private/legacy/OC_Hook.php - line 105:

    OC\Files\Node\HookConnector->postWrite()

    /var/www/nextcloud/lib/private/Files/View.php - line 643:

    OC_Hook::emit()

    /var/www/nextcloud/lib/private/Files/View.php - line 694:

    OC\Files\View->emit_file_hooks_post()

    /var/www/nextcloud/lib/private/Files/Node/File.php - line 71:

    OC\Files\View->file_put_contents()

    /var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php - line 503:

    OC\Files\Node\File->putContent()

    /var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php - line 785:

    OCA\Richdocuments\Controller\WopiController->OCA\Richdocuments\Controller\{closure}("*** sensiti ... *")

    /var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php - line 762:

    OCA\Richdocuments\Controller\WopiController->retryOperation()

    /var/www/nextcloud/lib/private/Files/Lock/LockManager.php - line 29:

    OCA\Richdocuments\Controller\WopiController->OCA\Richdocuments\Controller\{closure}("*** sensiti ... *")

    /var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php - line 765:

    OC\Files\Lock\LockManager->runInScope()

    /var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php - line 504:

    OCA\Richdocuments\Controller\WopiController->wrappedFilesystemOperation()

    /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 230:

    OCA\Richdocuments\Controller\WopiController->putFile()

    /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 137:

    OC\AppFramework\Http\Dispatcher->executeController()

    /var/www/nextcloud/lib/private/AppFramework/App.php - line 183:

    OC\AppFramework\Http\Dispatcher->dispatch()

    /var/www/nextcloud/lib/private/Route/Router.php - line 315:

    OC\AppFramework\App::main()

    /var/www/nextcloud/lib/base.php - line 1055:

    OC\Route\Router->match()

    /var/www/nextcloud/index.php - line 36:

    OC::handleRequest()

Additional info

When running occ versions:expire -vvv

Exception trace:
  at /var/www/nextcloud/lib/private/Files/Node/Root.php:209
 OC\Files\Node\Root->get() at /var/www/nextcloud/lib/private/Files/Node/Folder.php:139
 OC\Files\Node\Folder->get() at /var/www/nextcloud/apps/files_versions/lib/Storage.php:595
 OCA\Files_Versions\Storage::OCA\Files_Versions\{closure}() at n/a:n/a
 array_filter() at /var/www/nextcloud/apps/files_versions/lib/Storage.php:610
 OCA\Files_Versions\Storage::expireOlderThanMaxForUser() at /var/www/nextcloud/apps/files_versions/lib/Command/ExpireVersions.php:110
 OCA\Files_Versions\Command\ExpireVersions->expireVersionsForUser() at /var/www/nextcloud/apps/files_versions/lib/Command/ExpireVersions.php:97
 OCA\Files_Versions\Command\ExpireVersions->OCA\Files_Versions\Command\{closure}() at /var/www/nextcloud/lib/private/User/Manager.php:639
 OC\User\Manager->callForSeenUsers() at /var/www/nextcloud/apps/files_versions/lib/Command/ExpireVersions.php:98
 OCA\Files_Versions\Command\ExpireVersions->execute() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/apps/recognize/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:215
 OC\Console\Application->run() at /var/www/nextcloud/console.php:100
 require_once() at /var/www/nextcloud/occ:11
danielb42 commented 1 year ago

With Nextcloud 26.0.0.11, I encounter a different error/stacktrace on occ versions:expire -vvv, I think it's related to this issue.

An unhandled exception has been thrown:
TypeError: OCP\AppFramework\Db\QBMapper::delete(): Argument #1 ($entity) must be of type OCP\AppFramework\Db\Entity, null given, called in /var/www/html/apps/files_versions/lib/Storage.php on line 615 and defined in /var/www/html/lib/public/AppFramework/Db/QBMapper.php:96
Stack trace:
#0 /var/www/html/apps/files_versions/lib/Storage.php(615): OCP\AppFramework\Db\QBMapper->delete(NULL)
#1 /var/www/html/apps/files_versions/lib/Command/ExpireVersions.php(110): OCA\Files_Versions\Storage::expireOlderThanMaxForUser('daniel')
#2 /var/www/html/apps/files_versions/lib/Command/ExpireVersions.php(97): OCA\Files_Versions\Command\ExpireVersions->expireVersionsForUser(Object(OC\User\User))
#3 /var/www/html/lib/private/User/Manager.php(639): OCA\Files_Versions\Command\ExpireVersions->OCA\Files_Versions\Command\{closure}(Object(OC\User\User))
#4 /var/www/html/apps/files_versions/lib/Command/ExpireVersions.php(98): OC\User\Manager->callForSeenUsers(Object(Closure))
#5 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\Files_Versions\Command\ExpireVersions->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/html/3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files_Versions\Command\ExpireVersions), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/console.php(100): OC\Console\Application->run()
#11 /var/www/html/occ(11): require_once('/var/www/html/c...')
#12 {main}

Nextcloud log also contains this line with the same timestamp as the above event: Undefined array key 750136 at /var/www/html/apps/files_versions/lib/Storage.php#615

And finally, this: (anyone knows how to break long lines?)

{"reqId":"uhtZoPXGKlze4PjKLXiN","level":3,"time":"2023-04-09T08:15:03+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"Error while running background job (class: OCA\\Files_Versions\\BackgroundJob\\ExpireVersions, arguments: )","userAgent":"--","version":"26.0.0.11","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"/daniel/files/SofortUpload/hub4.txt","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/Node/Folder.php","line":139,"function":"get","class":"OC\\Files\\Node\\Root","type":"->","args":["/daniel/files/SofortUpload/hub4.txt"]},{"file":"/var/www/html/apps/files_versions/lib/Storage.php","line":595,"function":"get","class":"OC\\Files\\Node\\Folder","type":"->","args":["/SofortUpload/hub4.txt"]},{"function":"OCA\\Files_Versions\\{closure}","class":"OCA\\Files_Versions\\Storage","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/files_versions/lib/Storage.php","line":610,"function":"array_filter","args":[["*** sensitive parameters replaced ***","*** sensitive parameters replaced ***","*** sensitive parameters replaced ***","*** sensitive parameters replaced ***","*** sensitive parameters replaced ***","And 44 more entries, set log level to debug to see all entries"],["Closure"]]},{"file":"/var/www/html/apps/files_versions/lib/BackgroundJob/ExpireVersions.php","line":69,"function":"expireOlderThanMaxForUser","class":"OCA\\Files_Versions\\Storage","type":"::","args":["daniel"]},{"file":"/var/www/html/lib/private/User/Manager.php","line":639,"function":"OCA\\Files_Versions\\BackgroundJob\\{closure}","class":"OCA\\Files_Versions\\BackgroundJob\\ExpireVersions","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/files_versions/lib/BackgroundJob/ExpireVersions.php","line":70,"function":"callForSeenUsers","class":"OC\\User\\Manager","type":"->","args":[["Closure"]]},{"file":"/var/www/html/lib/public/BackgroundJob/Job.php","line":78,"function":"run","class":"OCA\\Files_Versions\\BackgroundJob\\ExpireVersions","type":"->","args":[null]},{"file":"/var/www/html/lib/public/BackgroundJob/TimedJob.php","line":103,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->","args":[["OC\\BackgroundJob\\JobList"]]},{"file":"/var/www/html/lib/public/BackgroundJob/TimedJob.php","line":93,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->","args":[["OC\\BackgroundJob\\JobList"]]},{"file":"/var/www/html/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->","args":[["OC\\BackgroundJob\\JobList"],["OC\\Log"]]}],"File":"/var/www/html/lib/private/Files/Node/Root.php","Line":209,"message":"Error while running background job (class: OCA\\Files_Versions\\BackgroundJob\\ExpireVersions, arguments: )","exception":{},"CustomMessage":"Error while running background job (class: OCA\\Files_Versions\\BackgroundJob\\ExpireVersions, arguments: )"}}

The file in question, hub4.txt, and none of its versions are present on any of NCs filesystems anymore. occ files:cleanup and occ files:scan --all don't stop Nextcloud from periodically trying to remove its version and so the mentioned errors are thrown.

skjnldsv commented 1 year ago

I can reproduce the issue on file upload

{
  "reqId": "CTudhUurLxOS27C3TxUV",
  "level": 3,
  "time": "2023-04-29T06:57:24+00:00",
  "remoteAddr": "xxx.xxx.xxx.xxx",
  "user": "xxxxxxxxxxx",
  "app": "no app in context",
  "method": "PUT",
  "url": "/remote.php/dav/files/xxxxxxxxxx/InstantUpload/2023/04/20230409_174200.jpg",
  "message": "Did expect one result but found none when executing: query \"SELECT * FROM `*PREFIX*files_versions` WHERE (`file_id` = :dcValue1) AND (`timestamp` = :dcValue2)\"; ",
  "userAgent": "Mozilla/5.0 (Linux) mirall/3.8.1git (Nextcloud, arch-6.2.12-arch1-1 ClientArchitecture: x86_64 OsArchitecture: x86_64)",
  "version": "26.0.1.1",
  "exception": {
    "Exception": "OCP\\AppFramework\\Db\\DoesNotExistException",
    "Message": "Did expect one result but found none when executing: query \"SELECT * FROM `*PREFIX*files_versions` WHERE (`file_id` = :dcValue1) AND (`timestamp` = :dcValue2)\"; ",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
        "line": 361,
        "function": "findOneQuery",
        "class": "OCP\\AppFramework\\Db\\QBMapper",
        "type": "->",
        "args": [
          [
            "OC\\DB\\QueryBuilder\\QueryBuilder"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/files_versions/lib/Db/VersionsMapper.php",
        "line": 78,
        "function": "findEntity",
        "class": "OCP\\AppFramework\\Db\\QBMapper",
        "type": "->",
        "args": [
          [
            "OC\\DB\\QueryBuilder\\QueryBuilder"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/files_versions/lib/Listener/FileEventsListener.php",
        "line": 242,
        "function": "findVersionForFileId",
        "class": "OCA\\Files_Versions\\Db\\VersionsMapper",
        "type": "->",
        "args": [
          180544,
          1681139688
        ]
      },
      {
        "file": "/var/www/html/apps/files_versions/lib/Listener/FileEventsListener.php",
        "line": 106,
        "function": "post_write_hook",
        "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
        "type": "->",
        "args": [
          [
            "OC\\Files\\Node\\File"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php",
        "line": 86,
        "function": "handle",
        "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
        "type": "->",
        "args": [
          [
            "OCP\\Files\\Events\\Node\\NodeWrittenEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 251,
        "function": "__invoke",
        "class": "OC\\EventDispatcher\\ServiceEventListener",
        "type": "->",
        "args": [
          [
            "OCP\\Files\\Events\\Node\\NodeWrittenEvent"
          ],
          "OCP\\Files\\Events\\Node\\NodeWrittenEvent",
          [
            "Symfony\\Component\\EventDispatcher\\EventDispatcher"
          ]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 73,
        "function": "callListeners",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            [
              "Closure"
            ],
            [
              "Closure"
            ],
            [
              "Closure"
            ]
          ],
          "OCP\\Files\\Events\\Node\\NodeWrittenEvent",
          [
            "OCP\\Files\\Events\\Node\\NodeWrittenEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 87,
        "function": "dispatch",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            "OCP\\Files\\Events\\Node\\NodeWrittenEvent"
          ],
          "OCP\\Files\\Events\\Node\\NodeWrittenEvent"
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 99,
        "function": "dispatch",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          "OCP\\Files\\Events\\Node\\NodeWrittenEvent",
          [
            "OCP\\Files\\Events\\Node\\NodeWrittenEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/HookConnector.php",
        "line": 118,
        "function": "dispatchTyped",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            "OCP\\Files\\Events\\Node\\NodeWrittenEvent"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/legacy/OC_Hook.php",
        "line": 105,
        "function": "postWrite",
        "class": "OC\\Files\\Node\\HookConnector",
        "type": "->",
        "args": [
          [
            "/InstantUpload/2023/04/20230409_174200.jpg"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/dav/lib/Connector/Sabre/File.php",
        "line": 471,
        "function": "emit",
        "class": "OC_Hook",
        "type": "::",
        "args": [
          "OC_Filesystem",
          "post_write",
          [
            "/InstantUpload/2023/04/20230409_174200.jpg"
          ]
        ]
      },
      {
        "file": "/var/www/html/apps/dav/lib/Connector/Sabre/File.php",
        "line": 398,
        "function": "emitPostHooks",
        "class": "OCA\\DAV\\Connector\\Sabre\\File",
        "type": "->",
        "args": [
          true
        ]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 1137,
        "function": "put",
        "class": "OCA\\DAV\\Connector\\Sabre\\File",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
        "line": 492,
        "function": "updateFile",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpPut",
        "class": "Sabre\\DAV\\CorePlugin",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "method:PUT",
          [
            [
              "Sabre\\HTTP\\Request"
            ],
            [
              "Sabre\\HTTP\\Response"
            ]
          ]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ]
        ]
      },
      {
        "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 321,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/apps/dav/lib/Server.php",
        "line": 366,
        "function": "exec",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/apps/dav/appinfo/v2/remote.php",
        "line": 35,
        "function": "exec",
        "class": "OCA\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/remote.php",
        "line": 172,
        "args": [
          "/var/www/html/apps/dav/appinfo/v2/remote.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
    "Line": 284,
    "CustomMessage": "--"
  }
}
szaimen commented 1 year ago

Cc @artonge

frlan commented 1 year ago

I'm seeing it by cron-Job run

TypeError: OCP\AppFramework\Db\QBMapper::delete(): Argument #1 ($entity) must be of type OCP\AppFramework\Db\Entity, null given, called in /srv/nc/apps/files_versions/lib/Storage.php on line 615 and defined in /srv/nc/lib/public/AppFramework/Db/QBMapper.php:96
Stack trace:
#0 /srv/nc/apps/files_versions/lib/Storage.php(615): OCP\AppFramework\Db\QBMapper->delete()
#1 /srv/nc/apps/files_versions/lib/BackgroundJob/ExpireVersions.php(69): OCA\Files_Versions\Storage::expireOlderThanMaxForUser()
#2 /srv/nc/lib/private/User/Manager.php(639): OCA\Files_Versions\BackgroundJob\ExpireVersions->OCA\Files_Versions\BackgroundJob\{closure}()
#3 /srv/nc/apps/files_versions/lib/BackgroundJob/ExpireVersions.php(70): OC\User\Manager->callForSeenUsers()
#4 /srv/nc/lib/public/BackgroundJob/Job.php(78): OCA\Files_Versions\BackgroundJob\ExpireVersions->run()
#5 /srv/nc/lib/public/BackgroundJob/TimedJob.php(103): OCP\BackgroundJob\Job->start()
#6 /srv/nc/lib/public/BackgroundJob/TimedJob.php(93): OCP\BackgroundJob\TimedJob->start()
#7 /srv/nc/cron.php(152): OCP\BackgroundJob\TimedJob->execute()
#8 {main}

Running Nextcloud 26.0.1.1 on PostgreSQL with PHP 8.1

artonge commented 10 months ago

Closing, as I was not able to reproduce. Feel free to reopen if the issue is still occurring. If you reopen, please include some reproduction steps to get into a state where occ versions:expire fails.