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

Error while running background job ExpireGroupVersions (with groupfolders 17.0.0). TypeError: VersionsBackend::getVersionFolderForFile(): Argument #1 ($file) must be of type OCP\Files\File, OC\Files\FileInfo given #2964

Closed
prolibre opened this issue May 21, 2024 · 19 comments · Fixed by #2989
Labels
1. to develop Issues that are ready for development bug feature: versions Items related to file versioning

Comments

@prolibre
Copy link

prolibre commented May 21, 2024

Nextcloud 29.0.0 and Nextcloud 29.0.1
The latest groupfolders update (17.0.0) introduces a new bug in the logs.

Reported by @jmechnich at #2935

{
  "reqId": "0okAL3KAiSQD23u5JJlv",
  "level": 3,
  "time": "2024-05-21T03:50:03+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "core",
  "method": "",
  "url": "--",
  "message": "Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (id: 102515, arguments: null)",
  "userAgent": "--",
  "version": "29.0.0.19",
  "exception": {
    "Exception": "TypeError",
    "Message": "OCA\\GroupFolders\\Versions\\VersionsBackend::getVersionFolderForFile(): ArgumeError while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersionsnt #1 ($file) must be of type OCP\\Files\\File, OC\\Files\\FileInfo given, called in /var/www/nextcloud/apps/groupfolders/lib/Versions/VersionsBackend.php on line 92",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/apps/groupfolders/lib/Versions/VersionsBackend.php",
        "line": 92,
        "function": "getVersionFolderForFile",
        "class": "OCA\\GroupFolders\\Versions\\VersionsBackend",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
        "line": 81,
        "function": "getVersionsForFile",
        "class": "OCA\\GroupFolders\\Versions\\VersionsBackend",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
        "line": 60,
        "function": "expireFolder",
        "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/groupfolders/lib/BackgroundJob/ExpireGroupVersions.php",
        "line": 43,
        "function": "expireAll",
        "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/Job.php",
        "line": 80,
        "function": "run",
        "class": "OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php",
        "line": 102,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php",
        "line": 92,
        "function": "start",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/cron.php",
        "line": 176,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      }
    ],
    "File": "/var/www/nextcloud/apps/groupfolders/lib/Versions/VersionsBackend.php",
    "Line": 78,
    "message": "Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (id: 102515, arguments: null)",
    "exception": {},
    "CustomMessage": "Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (id: 102515, arguments: null)"
  }
}

Have a nice day.

@prolibre prolibre added 0. Needs triage Issues that need to be triaged bug labels May 21, 2024
@prolibre prolibre changed the title Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (with groupfolders 19.0.0) Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (with groupfolders 17.0.0) May 21, 2024
@HuguesDug

This comment was marked as duplicate.

@baltaner

This comment was marked as duplicate.

@Dennis1993

This comment was marked as duplicate.

@urmel1960

This comment was marked as duplicate.

@contoporte

This comment was marked as duplicate.

@ReimuHakurei
Copy link

Needs testing, but from what I can see in the NC code, File extends Node which extends FileInfo, so this could possibly be fixed by doing the following.

In groupfolders/lib/Versions/GroupVersion.php, replace:
private File $versionFile, with private FileInfo $versionFile,

In groupfolders/lib/Versions/VersionsBackend.php, replace:
private function getFolderIdForFile(File $file): int {
with
private function getFolderIdForFile(FileInfo $file): int {

public function getVersionFolderForFile(File $file): Folder {
with
public function getVersionFolderForFile(FileInfo $file): Folder {

Someone who is actually familiar with the codebase here should verify this isn't going to horribly break anything.

@PaddySwiss

This comment was marked as duplicate.

@baltaner
Copy link

@ReimuHakurei
your suggested changes are stopping the errors on my server - groupfolders is still working...

@prolibre
Copy link
Author

@ReimuHakurei your suggested changes are stopping the errors on my server - groupfolders is still working...

+1 @baltaner

@s0undy
Copy link

s0undy commented May 27, 2024

same issue here.

Applied changes proposed by @ReimuHakurei and it fixes the error.

Verified by manually running occ groupfolders:expire which completed without errors.

@raffaelone
Copy link

Needs testing, but from what I can see in the NC code, File extends Node which extends FileInfo, so this could possibly be fixed by doing the following.

In groupfolders/lib/Versions/GroupVersion.php, replace: private File $versionFile, with private FileInfo $versionFile,

In groupfolders/lib/Versions/VersionsBackend.php, replace: private function getFolderIdForFile(File $file): int { with private function getFolderIdForFile(FileInfo $file): int {

public function getVersionFolderForFile(File $file): Folder { with public function getVersionFolderForFile(FileInfo $file): Folder {

Someone who is actually familiar with the codebase here should verify this isn't going to horribly break anything.

Appling this fix I take another error from logs

TypeError
OCA\GroupFolders\Versions\GroupVersion::getVersionFile(): Return value must be of type OCP\Files\File, OC\Files\FileInfo returned
Error while running background job OCA\GroupFolders\BackgroundJob\ExpireGroupVersions (id: 31591, arguments: null)

@klatka
Copy link

klatka commented May 28, 2024

Needs testing, but from what I can see in the NC code, File extends Node which extends FileInfo, so this could possibly be fixed by doing the following.

In groupfolders/lib/Versions/GroupVersion.php, replace: private File $versionFile, with private FileInfo $versionFile,

In groupfolders/lib/Versions/VersionsBackend.php, replace: private function getFolderIdForFile(File $file): int { with private function getFolderIdForFile(FileInfo $file): int {

public function getVersionFolderForFile(File $file): Folder { with public function getVersionFolderForFile(FileInfo $file): Folder {

Someone who is actually familiar with the codebase here should verify this isn't going to horribly break anything.

One was missing:

In groupfolders/lib/Versions/GroupVersion.php, replace: public function getVersionFile(): File { with public function getVersionFile(): FileInfo {

@raffaelone
Copy link

One was missing:

In groupfolders/lib/Versions/GroupVersion.php, replace: public function getVersionFile(): File { with public function getVersionFile(): FileInfo {

Error disappeared and the app works correctly. Manually running occ groupfolders:expire is completed without errors.
Thanks

@ordilibre
Copy link

Same context expect on Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-107-generic x86_64); same error encountered.

Applied changes proposed by @ReimuHakurei and it fixes the error.
Verified by manually running occ groupfolders:expire which completed without errors.

Thank you

@alphasixtyfive

This comment was marked as off-topic.

@solracsf solracsf changed the title Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (with groupfolders 17.0.0) Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (with groupfolders 17.0.0). TypeError OCA\GroupFolders\Versions\VersionsBackend::getVersionFolderForFile(): Argument #1 ($file) must be of type OCP\Files\File, OC\Files\FileInfo given May 29, 2024
helmo added a commit to helmo/groupfolders that referenced this issue Jun 1, 2024
@helmo

This comment was marked as outdated.

@solracsf

This comment was marked as outdated.

@solracsf solracsf changed the title Error while running background job OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions (with groupfolders 17.0.0). TypeError OCA\GroupFolders\Versions\VersionsBackend::getVersionFolderForFile(): Argument #1 ($file) must be of type OCP\Files\File, OC\Files\FileInfo given Error while running background job ExpireGroupVersions (with groupfolders 17.0.0). TypeError: VersionsBackend::getVersionFolderForFile(): Argument #1 ($file) must be of type OCP\Files\File, OC\Files\FileInfo given Jun 2, 2024
@solracsf
Copy link
Member

solracsf commented Jun 2, 2024

Hi @artonge as you've worked on this, can you take a look when possible? Thanks 👍

@solracsf solracsf added 1. to develop Issues that are ready for development feature: versions Items related to file versioning and removed 0. Needs triage Issues that need to be triaged labels Jun 2, 2024
@s0undy
Copy link

s0undy commented Jun 4, 2024

Applied #2989 in my production environment and looks like it fixes the issue. Unsure how to completely veriy, i ran occ groupfolders:expire manually without errors. No errors from background jobs either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Issues that are ready for development bug feature: versions Items related to file versioning
Projects
None yet
Development

Successfully merging a pull request may close this issue.