Storage::getUidAndFilename($source) not working in Nextcloud 30 anymore?

I’m trying to update the Nextcloud App QOwnNotesAPI for Nextcloud 30, but I get an internal server error in Nextcloud, triggered by Storage::getUidAndFilename($source);.

I get this Nextcloud error in \OCA\QOwnNotesAPI\Controller\NoteApiController::getAllVersions when trying to access the versions of a file: Call to a member function getOwner() on null in file '/var/www/html/lib/private/Files/Filesystem.php' line 728. :thinking:

        public static function getOwner($path) {
                return self::$defaultInstance->getOwner($path);
        }

https://github.com/nextcloud/server/blob/6c7d79b6960813d36dbad51f6fb74a6adaf75c4d/lib/private/Files/Filesystem.php#L721-L729

This is triggered by:

Are you not supposed to call Storage::getUidAndFilename($source); anymore?

1 Like

This is the full dump:

{
  "reqId": "fQJ35bznyRARookhrV8z",
  "level": 3,
  "time": "2024-09-16T18:42:30+00:00",
  "remoteAddr": "172.22.0.1",
  "user": "admin",
  "app": "index",
  "method": "GET",
  "url": "/index.php/apps/qownnotesapi/api/v1/note/versions?format=json&file_name=/Notes.bak/Link%20Destination.md",
  "message": "Call to a member function getOwner() on null in file '/var/www/html/lib/private/Files/Filesystem.php' line 728",  
  "userAgent": "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a3pre) Gecko/20070330",
  "version": "30.0.0.14",
  "exception": {
    "Exception": "Exception",
    "Message": "Call to a member function getOwner() on null in file '/var/www/html/lib/private/Files/Filesystem.php' line 728",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 161,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\QOwnNotesAPI\\Controller\\NoteApiController"
          ],
          "getAllVersions"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\QOwnNotesAPI\\Controller\\NoteApiController",
          "getAllVersions",
          [
            "OC\\AppFramework\\DependencyInjection\\DIContainer"
          ],
          [
            "qownnotesapi.note_api.get_all_versions"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 1001,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/qownnotesapi/api/v1/note/versions"
        ]
      },
      {
        "file": "/var/www/html/index.php",
        "line": 24,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
    "Line": 146,
    "Previous": {
      "Exception": "Error",
      "Message": "Call to a member function getOwner() on null",
      "Code": 0,
      "Trace": [
        {
          "file": "/var/www/html/apps/files_versions/lib/Storage.php",
          "line": 83,
          "function": "getOwner",
          "class": "OC\\Files\\Filesystem",
          "type": "::",
          "args": [
            "/Notes.bak/Link Destination.md"
          ]
        },
        {
          "file": "/var/www/html/custom_apps/qownnotesapi/lib/Controller/NoteApiController.php",
          "line": 62,
          "function": "getUidAndFilename",
          "class": "OCA\\Files_Versions\\Storage",
          "type": "::",
          "args": [
            "/Notes.bak/Link Destination.md"
          ]
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 208,
          "function": "getAllVersions",
          "class": "OCA\\QOwnNotesAPI\\Controller\\NoteApiController",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 114,
          "function": "executeController",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            [
              "OCA\\QOwnNotesAPI\\Controller\\NoteApiController"
            ],
            "getAllVersions"
          ]
        },
        {
          "file": "/var/www/html/lib/private/AppFramework/App.php",
          "line": 161,
          "function": "dispatch",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            [
              "OCA\\QOwnNotesAPI\\Controller\\NoteApiController"
            ],
            "getAllVersions"
          ]
        },
        {
          "file": "/var/www/html/lib/private/Route/Router.php",
          "line": 302,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::",
          "args": [
            "OCA\\QOwnNotesAPI\\Controller\\NoteApiController",
            "getAllVersions",
            [
              "OC\\AppFramework\\DependencyInjection\\DIContainer"
            ],
            [
              "qownnotesapi.note_api.get_all_versions"
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/base.php",
          "line": 1001,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->",
          "args": [
            "/apps/qownnotesapi/api/v1/note/versions"
          ]
        },
        {
          "file": "/var/www/html/index.php",
          "line": 24,
          "function": "handleRequest",
          "class": "OC",
          "type": "::",
          "args": []
        }
      ],
      "File": "/var/www/html/lib/private/Files/Filesystem.php",
      "Line": 728
    },
    "message": "Call to a member function getOwner() on null in file '/var/www/html/lib/private/Files/Filesystem.php' line 728",
    "exception": {},
    "CustomMessage": "Call to a member function getOwner() on null in file '/var/www/html/lib/private/Files/Filesystem.php' line 728"
  }
}

Generally speaking, the method is not marked as deprecated. Honestly, I am a bit suspicious about using foreign app’s classes (everything under OCA that belongs not to your own app). In this case it might be okay as the files_version is part of the NC server anyways.

Just to make sure, this is not the problem: Is the file_versions app enabled and is there a check for it?

1 Like

Thank you for formatting the JSON.
I also found no indication that Storage::getUidAndFilename is deprecated. Nothing meaningful changed in those files for a long time.

I just had the issue that $defaultInstance from

…was not always initialized.

I was using the v30 docker image (that will soon be built), featuring Nextcloud 30.0.0.14. I tried back and forth with NC 29 and NC 28 and never had any issues.

The Versions app (Version 1.23.0) is enabled, and I even check all needed apps in QOwnNotesAPI.

The really weird thing is that now and then $defaultInstance was initialized and then everything was working as it should, but most of the time it wasn’t. I relay fear there is some strange issue in Nextcloud 30. :grimacing: I didn’t have any issue with the API since Nextcloud 10. :grimacing:

Honestly, I am a bit suspicious about using foreign app’s classes (everything under OCA that belongs not to your own app).

Dunno, am I supposed to duplicate the functionality? I would if I should. It worked so far. And I wasn’t using private API (which I was doing for ownbackup, later nextbackup) until the API was gone. :sweat_smile:

This is still an issue with the current production docker image. :grimacing:

I can work around it by implementing parts of the versioning app myself. Still weird, but it worked.