Skip to content

Unshare feature is incomplete for groups when a user tries to unshare/delete a file #26346

@GustavoSLinden

Description

@GustavoSLinden

Steps to reproduce

  1. Create a group and assign 2 members (user1 and user2).
  2. Share a file with user1 to the group.
  3. Unshare the file with user2.

Expected behaviour

Everything should work perfectly.

Actual behaviour

The file is correctly unshared but after these 3 errors some functions did not work correctly:

{"reqId":"iaLbkobz6NFFnbKTN5ZT","remoteAddr":"10.35.82.142","app":"PHP","message":"Undefined index: shareType at \/var\/www\/nextcloud\/apps\/files_sharing\/lib\/updater.php#172","level":3,"time":"2016-10-11T19:25:29+00:00","method":"DELETE","url":"\/remote.php\/webdav\/test.txt","user":"user2"}
{"reqId":"iaLbkobz6NFFnbKTN5ZT","remoteAddr":"10.35.82.142","app":"PHP","message":"Undefined index: shareWith at \/var\/www\/nextcloud\/apps\/files_sharing\/lib\/updater.php#177","level":3,"time":"2016-10-11T19:25:29+00:00","method":"DELETE","url":"\/remote.php\/webdav\/test.txt","user":"user2"}
{"reqId":"iaLbkobz6NFFnbKTN5ZT","remoteAddr":"10.35.82.142","app":"PHP","message":"Undefined index: fileTarget at \/var\/www\/nextcloud\/apps\/files_sharing\/lib\/updater.php#177","level":3,"time":"2016-10-11T19:25:29+00:00","method":"DELETE","url":"\/remote.php\/webdav\/test.txt","user":"user2"}

Server configuration

Operating system: Debian 7 x86_64

Web server: Apache 2.2

Database: Postgresql 9.4

PHP version: 5.4.45-0+deb7u2

ownCloud version: 9.0.1

Updated from an older ownCloud or fresh install: Updated

Logs

ownCloud log (data/owncloud.log)

{"reqId":"iaLbkobz6NFFnbKTN5ZT","remoteAddr":"10.35.82.142","app":"PHP","message":"Undefined index: shareType at \/var\/www\/nextcloud\/apps\/files_sharing\/lib\/updater.php#172","level":3,"time":"2016-10-11T19:25:29+00:00","method":"DELETE","url":"\/remote.php\/webdav\/test.txt","user":"user2"}
{"reqId":"iaLbkobz6NFFnbKTN5ZT","remoteAddr":"10.35.82.142","app":"PHP","message":"Undefined index: shareWith at \/var\/www\/nextcloud\/apps\/files_sharing\/lib\/updater.php#177","level":3,"time":"2016-10-11T19:25:29+00:00","method":"DELETE","url":"\/remote.php\/webdav\/test.txt","user":"user2"}
{"reqId":"iaLbkobz6NFFnbKTN5ZT","remoteAddr":"10.35.82.142","app":"PHP","message":"Undefined index: fileTarget at \/var\/www\/nextcloud\/apps\/files_sharing\/lib\/updater.php#177","level":3,"time":"2016-10-11T19:25:29+00:00","method":"DELETE","url":"\/remote.php\/webdav\/test.txt","user":"user2"}

Workaround

This patch could be applied to correct the errors:

--- /var/www/owncloud/apps/files_sharing/lib/updater.php    2016-10-11 17:58:35.121227338 -0300
+++ /var/www/owncloud/apps/files_sharing/lib/updater.php    2016-10-11 18:00:05.449227352 -0300
@@ -168,10 +168,15 @@
    static public function postUnshareFromSelfHook($params) {
        if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
            foreach ($params['unsharedItems'] as $item) {
-               if ($item['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) {
+               if ( isset($item['shareType']) && $item['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) {
                    foreach (\OC_Group::usersInGroup($item['shareWith']) as $user) {
                        self::correctUsersFolder($user, $item['fileTarget']);
                    }
+               }
+               elseif ( isset($item['share_type']) && $item['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
+                   foreach (\OC_Group::usersInGroup($item['share_with']) as $user) {
+                                                self::correctUsersFolder($user, $item['file_target']);
+                                        }
                } else {
                    self::correctUsersFolder($item['shareWith'], $item['fileTarget']);
                }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions