nextcloud / groupfolders

📁👩‍👩‍👧‍👦 Admin-configured folders shared by everyone in a group. https://github.com/nextcloud-releases/groupfolders

Home Page:https://apps.nextcloud.com/apps/groupfolders

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined array key "group_details"

RenatoMorenoR opened this issue · comments

Hello friends, we have a problem in our platform, we see a constant error that appeared a couple of weeks ago.

Every time we want to add a group directory via API we get the error

“method”: “POST”, “url”:“/index.php/apps/groupfolders/folders”, “message”: “Undefined array key \”group_details“ at /usr/share/webapps/nextcloud/apps/groupfolders/lib/Controller/FolderController.php#307”, “userAgent”:“--”, “version”: “28.0.3.2”, “data”:{“app”: “PHP”}

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. add a group directory from the API

Expected behavior

You should be able to create the directory without error in the error logo.

Actual behavior

The directory is created without problem, but sends the error message to the system.

This is the problem function

private function folderDataForXML(array $data): array {
		$groups = $data['group_details'];
		$data['groups'] = [];
		unset($data['group_details']);
		foreach ($groups as $id => $group) {
			$data['groups'][] = [
				'@group_id' => $id,
				'@permissions' => $group['permissions'],
				'@display-name' => $group['displayName'],
				'@type' => $group['type'],
			];
		}
		return $data;
	}

Perhaps if you include a simple validation as shown here, you could avoid this error.

private function folderDataForXML(array $data): array {
                if(!is_null($data['group_details'])) {
		  $groups = $data['group_details'];
		  $data['groups'] = [];
		  unset($data['group_details']);
		  foreach ($groups as $id => $group) {
			$data['groups'][] = [
				'@group_id' => $id,
				'@permissions' => $group['permissions'],
				'@display-name' => $group['displayName'],
				'@type' => $group['type'],
			];
		  }
                }
		return $data;
	}

Server configuration

Operating system:
Ubuntu 22.04

Web server:
Nginx

Database:
Mysql
PHP version:
8.1
Nextcloud version: (see Nextcloud admin page)
28.0.3.2
Group folders version:
16.0.6
Updated from an older Nextcloud/ownCloud or fresh install:
Yes
Where did you install Nextcloud from:
N/A
Are you using external storage, if yes which one: local/s3/smb/sftp/...
NFS
Are you using encryption: yes/no
no
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/Saml/...
SAML

Logs

Web server error log

Web server error log
NextCloud[759329]: {"reqId":"T3V9xGQcMJADhTp0SjBh","level":3,"time":"2024-05-10T12:05:12+00:00","remoteAddr":"xx.xx.xxx.xx","user":"USER","app":"PHP","method":"POST","url":"/index.php/apps/groupfolders/folders","message":"Undefined array key \"group_details\" at /usr/share/webapps/nextcloud/apps/groupfolders/lib/Controller/FolderController.php#307","userAgent":"--","version":"28.0.3.2","data":{"app":"PHP"}}
2024-05-10T12:05:12+00:00 xxxx.xxx.xxx NextCloud[759329]: {"reqId":"T3V9xGQcMJADhTp0SjBh","level":3,"time":"2024-05-10T12:05:12+00:00","remoteAddr":"xx.xxx.xxx.xx","user":"USER","app":"PHP","method":"POST","url":"/index.php/apps/groupfolders/folders","message":"foreach() argument must be of type array|object, null given at /usr/share/webapps/nextcloud/apps/groupfolders/lib/Controller/FolderController.php#310","userAgent":"--","version":"28.0.3.2","data":{"app":"PHP"}}