Group-enable setting not preserved on app settings page #26638

mirekys opened this Issue Nov 15, 2016 · 4 comments


None yet

2 participants

mirekys commented Nov 15, 2016 edited

Steps to reproduce

  1. Restrict some app (e.g Gallery) to be available only for certain groups (e.g. "gallery-users")
  2. Reload the App settings page (you can see app's allowed groups in group_select field)
  3. Reload the App settings page again (group restrictions are now gone/not visible)
  4. Check the Groups-enable checkbox (it will clear all previous group restrictions even from database)

Expected behaviour

App's group restriction visible on App Settings page should always
correspond to what is being saved in DB appconfig table.

Actual behaviour

App's group restriction disappeared from the App Settings page after the second reload.
However, it was still stored correctly in database:

owncloud=# SELECT * FROM oc_appconfig WHERE appid='gallery' AND configkey ='enabled';
  appid  |     configkey     |    configvalue    
 gallery | enabled           | ["gallery-users"]
(3 rows)

I've found the problem is being caused by this code:

			// fix groups
			$groups = array();
			if (is_string($app['groups'])) {
				$groups = json_decode($app['groups']);
			$app['groups'] = $groups;
  • On the first page reoad, the $app['groups'] is being decoded from string to Array, and then saved to $this->cache.

  • On the second page reload, the $app['groups'] is being pulled from cache as Array of groups. The code above then incorrectly assigns an empty array to $app['groups'] and caches it.

I would suggest a following fix:

			// fix groups
			$groups = array();
			if (is_string($app['groups'])) {
				$groups = json_decode($app['groups']);
+			} elseif (is_array($app['groups'])) {
+                              $groups = $app['groups'];
+                       }
			$app['groups'] = $groups;

Server configuration

PostgreSQL 9.2
PHP version:
ownCloud version: (see ownCloud admin page)
Updated from an older ownCloud or fresh install:
Updated from 8.2.9
Where did you install ownCloud from:
official tar package

@PVince81 PVince81 added this to the 9.0.7 milestone Nov 21, 2016
@PVince81 PVince81 self-assigned this Nov 21, 2016
@PVince81 PVince81 modified the milestone: 9.0.8, 9.0.7 Nov 30, 2016

@mirekys mind sending your fix as a PR ? Thanks

@mirekys mirekys referenced this issue Nov 30, 2016

Fix for app groups setting preservation #26748

3 of 9 tasks complete
PVince81 commented Dec 1, 2016

I couldn't reproduce the issue but you mentioned a cache, so it's probably memcache ?
Trying that now

PVince81 commented Dec 1, 2016

Indeed, reproduceable with redis as local memcache.

PVince81 commented Dec 1, 2016

Fixed in #26748

@PVince81 PVince81 closed this Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment