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] Call to a member function setPermissions() on null #44314

Closed
skjnldsv opened this issue Mar 19, 2024 · 2 comments · Fixed by #44316
Closed

[Bug] Call to a member function setPermissions() on null #44314

skjnldsv opened this issue Mar 19, 2024 · 2 comments · Fixed by #44316

Comments

@skjnldsv
Copy link
Member

skjnldsv commented Mar 19, 2024

Regression from #44004

Context

image

Code

$shareMap[$data['parent']]->setPermissions((int)$data['permissions']);

Log

{
  "reqId": "kT3f4APf3ie4SV9q8UBV",
  "level": 3,
  "time": "2024-03-19T11:57:56+00:00",
  "remoteAddr": "172.18.0.1",
  "user": "admin",
  "app": "index",
  "method": "GET",
  "url": "/apps/files/files/334420?dir=/Photos/Test%20drop/Portraits",
  "message": "Call to a member function setPermissions() on null in file '/var/www/nextcloud/lib/private/Share20/DefaultShareProvider.php' line 1156",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
  "version": "29.0.0.10",
  "exception": {
    "Exception": "Exception",
    "Message": "Call to a member function setPermissions() on null in file '/var/www/nextcloud/lib/private/Share20/DefaultShareProvider.php' line 1156",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\Files\\Controller\\ViewController"
          ],
          "indexViewFileid"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Route/Router.php",
        "line": 338,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Files\\Controller\\ViewController",
          "indexViewFileid",
          [
            "OC\\AppFramework\\DependencyInjection\\DIContainer"
          ],
          [
            "files",
            "334420",
            "files.view.indexviewfileid"
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1050,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/files/files/334420"
        ]
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 49,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
    "Line": 170,
    "Previous": {
      "Exception": "Error",
      "Message": "Call to a member function setPermissions() on null",
      "Code": 0,
      "Trace": [
        {
          "file": "/var/www/nextcloud/lib/private/Share20/DefaultShareProvider.php",
          "line": 1019,
          "function": "resolveGroupShares",
          "class": "OC\\Share20\\DefaultShareProvider",
          "type": "->",
          "args": [
            [
              [
                "OC\\Share20\\Share"
              ],
              [
                "OC\\Share20\\Share"
              ],
              [
                "OC\\Share20\\Share"
              ],
              [
                "OC\\Share20\\Share"
              ],
              [
                "OC\\Share20\\Share"
              ],
              [
                "OC\\Share20\\Share"
              ],
              [
                "OC\\Share20\\Share"
              ]
            ],
            "admin"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Share20/Manager.php",
          "line": 1411,
          "function": "getSharedWith",
          "class": "OC\\Share20\\DefaultShareProvider",
          "type": "->",
          "args": [
            "admin",
            1,
            null,
            -1,
            0
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/files_sharing/lib/MountProvider.php",
          "line": 68,
          "function": "getSharedWith",
          "class": "OC\\Share20\\Manager",
          "type": "->",
          "args": [
            "admin",
            1,
            null,
            -1
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Config/MountProviderCollection.php",
          "line": 89,
          "function": "getMountsForUser",
          "class": "OCA\\Files_Sharing\\MountProvider",
          "type": "->",
          "args": [
            [
              "OC\\User\\User"
            ],
            [
              "OC\\Files\\Storage\\StorageFactory"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Config/MountProviderCollection.php",
          "line": 146,
          "function": "getMountsFromProvider",
          "class": "OC\\Files\\Config\\MountProviderCollection",
          "type": "->",
          "args": [
            [
              "OCA\\Files_Sharing\\MountProvider"
            ],
            [
              "OC\\User\\User"
            ],
            [
              "OC\\Files\\Storage\\StorageFactory"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/SetupManager.php",
          "line": 221,
          "function": "addMountForUser",
          "class": "OC\\Files\\Config\\MountProviderCollection",
          "type": "->",
          "args": [
            [
              "OC\\User\\User"
            ],
            [
              "OC\\Files\\Mount\\Manager"
            ],
            [
              "Closure"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/SetupManager.php",
          "line": 320,
          "function": "OC\\Files\\{closure}",
          "class": "OC\\Files\\SetupManager",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/SetupManager.php",
          "line": 222,
          "function": "setupForUserWith",
          "class": "OC\\Files\\SetupManager",
          "type": "->",
          "args": [
            [
              "OC\\User\\User"
            ],
            [
              "Closure"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/SetupManager.php",
          "line": 504,
          "function": "setupForUser",
          "class": "OC\\Files\\SetupManager",
          "type": "->",
          "args": [
            [
              "OC\\User\\User"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Mount/Manager.php",
          "line": 231,
          "function": "setupForProvider",
          "class": "OC\\Files\\SetupManager",
          "type": "->",
          "args": [
            "/admin/files",
            [
              "OC\\Files\\Mount\\LocalHomeMountProvider"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Node/Root.php",
          "line": 475,
          "function": "getMountsByMountProvider",
          "class": "OC\\Files\\Mount\\Manager",
          "type": "->",
          "args": [
            "/admin/files",
            [
              "OC\\Files\\Mount\\LocalHomeMountProvider"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Node/Root.php",
          "line": 427,
          "function": "getByIdInPath",
          "class": "OC\\Files\\Node\\Root",
          "type": "->",
          "args": [
            334420,
            "/admin/files"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Node/LazyFolder.php",
          "line": 499,
          "function": "getFirstNodeByIdInPath",
          "class": "OC\\Files\\Node\\Root",
          "type": "->",
          "args": [
            334420,
            "/admin/files"
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/files/lib/Controller/ViewController.php",
          "line": 347,
          "function": "getFirstNodeById",
          "class": "OC\\Files\\Node\\LazyFolder",
          "type": "->",
          "args": [
            334420
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/files/lib/Controller/ViewController.php",
          "line": 196,
          "function": "redirectToFileIfInTrashbin",
          "class": "OCA\\Files\\Controller\\ViewController",
          "type": "->",
          "args": [
            334420
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/files/lib/Controller/ViewController.php",
          "line": 179,
          "function": "index",
          "class": "OCA\\Files\\Controller\\ViewController",
          "type": "->",
          "args": [
            "/Photos/Test drop/Portraits",
            "files",
            "334420",
            false
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 232,
          "function": "indexViewFileid",
          "class": "OCA\\Files\\Controller\\ViewController",
          "type": "->",
          "args": [
            "/Photos/Test drop/Portraits",
            "files",
            "334420",
            false
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 138,
          "function": "executeController",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            [
              "OCA\\Files\\Controller\\ViewController"
            ],
            "indexViewFileid"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
          "line": 184,
          "function": "dispatch",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            [
              "OCA\\Files\\Controller\\ViewController"
            ],
            "indexViewFileid"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Route/Router.php",
          "line": 338,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::",
          "args": [
            "OCA\\Files\\Controller\\ViewController",
            "indexViewFileid",
            [
              "OC\\AppFramework\\DependencyInjection\\DIContainer"
            ],
            [
              "files",
              "334420",
              "files.view.indexviewfileid"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/base.php",
          "line": 1050,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->",
          "args": [
            "/apps/files/files/334420"
          ]
        },
        {
          "file": "/var/www/nextcloud/index.php",
          "line": 49,
          "function": "handleRequest",
          "class": "OC",
          "type": "::",
          "args": []
        }
      ],
      "File": "/var/www/nextcloud/lib/private/Share20/DefaultShareProvider.php",
      "Line": 1156
    },
    "message": "Call to a member function setPermissions() on null in file '/var/www/nextcloud/lib/private/Share20/DefaultShareProvider.php' line 1156",
    "exception": {},
    "CustomMessage": "Call to a member function setPermissions() on null in file '/var/www/nextcloud/lib/private/Share20/DefaultShareProvider.php' line 1156"
  }
}
@skjnldsv skjnldsv added enhancement 1. to develop Accepted and waiting to be taken care of 29-feedback labels Mar 19, 2024
@skjnldsv skjnldsv added this to the Nextcloud 29 milestone Mar 19, 2024
@skjnldsv
Copy link
Member Author

@icewind1991

@skjnldsv
Copy link
Member Author

Suggestion

diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index 213423d4755..c22c65f6c7b 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -1153,10 +1153,12 @@ class DefaultShareProvider implements IShareProvider {
                $stmt = $query->execute();
 
                while ($data = $stmt->fetch()) {
-                       $shareMap[$data['parent']]->setPermissions((int)$data['permissions']);
-                       $shareMap[$data['parent']]->setStatus((int)$data['accepted']);
-                       $shareMap[$data['parent']]->setTarget($data['file_target']);
-                       $shareMap[$data['parent']]->setParent($data['parent']);
+                       if (array_key_exists($data['parent'], $shareMap)) {
+                               $shareMap[$data['parent']]->setPermissions((int)$data['permissions']);
+                               $shareMap[$data['parent']]->setStatus((int)$data['accepted']);
+                               $shareMap[$data['parent']]->setTarget($data['file_target']);
+                               $shareMap[$data['parent']]->setParent($data['parent']);
+                       }
                }
 
                return array_values($shareMap);

@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 1. to develop Accepted and waiting to be taken care of labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant