Skip to content

Issue with Accessing String Offset on getParticipant() Return Value in PermissionHelperService #192

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
WallastonLouis opened this issue Mar 18, 2024 · 0 comments

Comments

@WallastonLouis
Copy link

I've encountered an issue within the PermissionHelperService class of our Nextcloud Health app, specifically when trying to access the getParticipant() method's return value. The error message encountered is:

Exception: Cannot access offset of type string on string in file '/var/www/nextcloud/apps/health/lib/Services/PermissionHelperService.php' on line 89.

Upon reviewing the code, it seems that the method getParticipant() is expected to return an array or an object that includes a "uid" key. However, the actual return value appears to be a string. This discrepancy leads to a critical error when attempting to access the "uid" offset as if the return value were an array or an object.

Here is the problematic segment of the code for your reference:

public function getSharedPersonsOfCurrentUser(array $acls): array {
$personIds = array();
foreach($acls as $acl) {
if ($acl->getType() == Acl::PERMISSION_TYPE_USER && $acl->getParticipant()["uid"] == $this->userId) {
$personIds[] = $acl->getPersonId();
}
if ($acl->getType() == Acl::PERMISSION_TYPE_GROUP && $this->groupManager->isInGroup($this->userId, $acl->getParticipant()["uid"])) {
$personIds[] = $acl->getPersonId();
}
}
...
}

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

No branches or pull requests

1 participant