Skip to content

fix(sharing): fix json decoding the list of groups excluded from sharing #53503

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tcitworld
Copy link
Member

@tcitworld tcitworld commented Jun 16, 2025

json_decode() returns stdclass by default instead of an associative object, which can't be used for array_diff or array_intersect later

This can prevent login as it's used when mounting user storages.

Summary

{
  "Exception": "Exception",
  "Message": "array_intersect(): Argument #2 must be of type array, stdClass given in file '/var/www/nc/nextcloud-30.0.10/lib/private/Share20/ShareDisableChecker.php' line 69",
  "Code": 0,
  "Trace": [
    {
      "file": "/var/www/nc/nextcloud-30.0.10/lib/private/AppFramework/App.php",
      "line": 161,
      "function": "dispatch",
      "class": "OC\\\\AppFramework\\\\Http\\\\Dispatcher",
      "type": "->"
    },
    {
      "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Route/Router.php",
      "line": 303,
      "function": "main",
      "class": "OC\\\\AppFramework\\\\App",
      "type": "::"
    },
    {
      "file": "/var/www/nc/nextcloud-30.0.10/lib/base.php",
      "line": 1010,
      "function": "match",
      "class": "OC\\\\Route\\\\Router",
      "type": "->"
    },
    {
      "file": "/var/www/nc/nextcloud-30.0.10/index.php",
      "line": 24,
      "function": "handleRequest",
      "class": "OC",
      "type": "::"
    }
  ],
  "File": "/var/www/nc/nextcloud-30.0.10/lib/private/AppFramework/Http/Dispatcher.php",
  "Line": 146,
  "Previous": {
    "Exception": "TypeError",
    "Message": "array_intersect(): Argument #2 must be of type array, stdClass given",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Share20/ShareDisableChecker.php",
        "line": 69,
        "function": "array_intersect"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Files/SetupManager.php",
        "line": 119,
        "function": "sharingDisabledForUser",
        "class": "OC\\\\Share20\\\\ShareDisableChecker",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Files/SetupManager.php",
        "line": 327,
        "function": "setupBuiltinWrappers",
        "class": "OC\\\\Files\\\\SetupManager",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Files/SetupManager.php",
        "line": 222,
        "function": "setupRoot",
        "class": "OC\\\\Files\\\\SetupManager",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Files/SetupManager.php",
        "line": 303,
        "function": "oneTimeUserSetup",
        "class": "OC\\\\Files\\\\SetupManager",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Files/SetupManager.php",
        "line": 202,
        "function": "setupForUserWith",
        "class": "OC\\\\Files\\\\SetupManager",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Files/Filesystem.php",
        "line": 332,
        "function": "setupForUser",
        "class": "OC\\\\Files\\\\SetupManager",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Cache/File.php",
        "line": 34,
        "function": "initMountPoints",
        "class": "OC\\\\Files\\\\Filesystem",
        "type": "::"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Cache/File.php",
        "line": 155,
        "function": "getStorage",
        "class": "OC\\\\Cache\\\\File",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/base.php",
        "line": 845,
        "function": "gc",
        "class": "OC\\\\Cache\\\\File",
        "type": "->"
      },
      {
        "function": "{closure}",
        "class": "OC",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Hooks/EmitterTrait.php",
        "line": 88,
        "function": "call_user_func_array"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Hooks/PublicEmitter.php",
        "line": 22,
        "function": "emit",
        "class": "OC\\\\Hooks\\\\BasicEmitter",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/User/Session.php",
        "line": 349,
        "function": "emit",
        "class": "OC\\\\Hooks\\\\PublicEmitter",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/CompleteLoginCommand.php",
        "line": 22,
        "function": "completeLogin",
        "class": "OC\\\\User\\\\Session",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/ALoginCommand.php",
        "line": 22,
        "function": "process",
        "class": "OC\\\\Authentication\\\\Login\\\\CompleteLoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/LoggedInCheckCommand.php",
        "line": 41,
        "function": "processNextOrFinishSuccessfully",
        "class": "OC\\\\Authentication\\\\Login\\\\ALoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/ALoginCommand.php",
        "line": 22,
        "function": "process",
        "class": "OC\\\\Authentication\\\\Login\\\\LoggedInCheckCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/EmailLoginCommand.php",
        "line": 51,
        "function": "processNextOrFinishSuccessfully",
        "class": "OC\\\\Authentication\\\\Login\\\\ALoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/ALoginCommand.php",
        "line": 22,
        "function": "process",
        "class": "OC\\\\Authentication\\\\Login\\\\EmailLoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/UidLoginCommand.php",
        "line": 36,
        "function": "processNextOrFinishSuccessfully",
        "class": "OC\\\\Authentication\\\\Login\\\\ALoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/ALoginCommand.php",
        "line": 22,
        "function": "process",
        "class": "OC\\\\Authentication\\\\Login\\\\UidLoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/UserDisabledCheckCommand.php",
        "line": 39,
        "function": "processNextOrFinishSuccessfully",
        "class": "OC\\\\Authentication\\\\Login\\\\ALoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/ALoginCommand.php",
        "line": 22,
        "function": "process",
        "class": "OC\\\\Authentication\\\\Login\\\\UserDisabledCheckCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/PreLoginHookCommand.php",
        "line": 34,
        "function": "processNextOrFinishSuccessfully",
        "class": "OC\\\\Authentication\\\\Login\\\\ALoginCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Authentication/Login/Chain.php",
        "line": 45,
        "function": "process",
        "class": "OC\\\\Authentication\\\\Login\\\\PreLoginHookCommand",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/core/Controller/LoginController.php",
        "line": 326,
        "function": "process",
        "class": "OC\\\\Authentication\\\\Login\\\\Chain",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 208,
        "function": "tryLogin",
        "class": "OC\\\\Core\\\\Controller\\\\LoginController",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 114,
        "function": "executeController",
        "class": "OC\\\\AppFramework\\\\Http\\\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/AppFramework/App.php",
        "line": 161,
        "function": "dispatch",
        "class": "OC\\\\AppFramework\\\\Http\\\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/private/Route/Router.php",
        "line": 303,
        "function": "main",
        "class": "OC\\\\AppFramework\\\\App",
        "type": "::"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/lib/base.php",
        "line": 1010,
        "function": "match",
        "class": "OC\\\\Route\\\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/nc/nextcloud-30.0.10/index.php",
        "line": 24,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/nc/nextcloud-30.0.10/lib/private/Share20/ShareDisableChecker.php",
    "Line": 69
  },
  "message": "array_intersect(): Argument #2 must be of type array, stdClass given in file '/var/www/nc/nextcloud-30.0.10/lib/private/Share20/ShareDisableChecker.php' line 69",
  "exception": {},
  "CustomMessage": "array_intersect(): Argument #2 must be of type array, stdClass g"
}

Checklist

json_decode() returns stdclass by default instead of an associative object, which can't be used for
array_diff or array_intersect later

Signed-off-by: Thomas Citharel <[email protected]>
@tcitworld tcitworld added this to the Nextcloud 32 milestone Jun 16, 2025
@tcitworld tcitworld requested review from icewind1991 and come-nc June 16, 2025 06:32
@tcitworld tcitworld requested a review from a team as a code owner June 16, 2025 06:32
@tcitworld tcitworld requested review from ArtificialOwl and removed request for a team June 16, 2025 06:32
@tcitworld
Copy link
Member Author

/backport to stable31

@tcitworld
Copy link
Member Author

/backport to stable30

Copy link
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code block with the fallback to comma-separated list is weird, we should have a migration if needed and only store as JSON.
But that’s not changed by this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants