use OCP\App\IAppManager;
use OCP\IAppConfig;
+use OCP\ICacheFactory;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
*/
private $groupManager;
+ /** @var \OCP\ICacheFactory */
+ private $memCacheFactory;
+
/**
* @var string[] $appId => $enabled
*/
* @param \OCP\IAppConfig $appConfig
* @param \OCP\IGroupManager $groupManager
*/
- public function __construct(IUserSession $userSession, IAppConfig $appConfig, IGroupManager $groupManager) {
+ public function __construct(IUserSession $userSession, IAppConfig $appConfig, IGroupManager $groupManager, ICacheFactory $memCacheFactory) {
$this->userSession = $userSession;
$this->appConfig = $appConfig;
$this->groupManager = $groupManager;
+ $this->memCacheFactory = $memCacheFactory;
}
/**
public function enableApp($appId) {
$this->installedAppsCache[$appId] = 'yes';
$this->appConfig->setValue($appId, 'enabled', 'yes');
+ $this->clearAppsCache();
}
/**
}, $groups);
$this->installedAppsCache[$appId] = json_encode($groupIds);
$this->appConfig->setValue($appId, 'enabled', json_encode($groupIds));
+ $this->clearAppsCache();
}
/**
}
unset($this->installedAppsCache[$appId]);
$this->appConfig->setValue($appId, 'enabled', 'no');
+ $this->clearAppsCache();
+ }
+
+ /**
+ * Clear the cached list of apps when enabling/disabling an app
+ */
+ protected function clearAppsCache() {
+ $settingsMemCache = $this->memCacheFactory->create('settings');
+ $settingsMemCache->clear('listApps');
}
}
return new TempManager(get_temp_dir(), $c->getLogger());
});
$this->registerService('AppManager', function(Server $c) {
- $userSession = $c->getUserSession();
- $appConfig = $c->getAppConfig();
- $groupManager = $c->getGroupManager();
- return new \OC\App\AppManager($userSession, $appConfig, $groupManager);
+ return new \OC\App\AppManager(
+ $c->getUserSession(),
+ $c->getAppConfig(),
+ $c->getGroupManager(),
+ $c->getMemCacheFactory()
+ );
});
$this->registerService('DateTimeZone', function(Server $c) {
return new DateTimeZone(
$appId = (string)$_POST['appid'];
$appId = OC_App::cleanAppId($appId);
-// FIXME: Clear the cache - move that into some sane helper method
-\OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-0');
-\OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-1');
-
OC_App::disable($appId);
OC_JSON::success();
try {
OC_App::enable(OC_App::cleanAppId((string)$_POST['appid']), $groups);
- // FIXME: Clear the cache - move that into some sane helper method
- \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-0');
- \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-1');
OC_JSON::success();
} catch (Exception $e) {
OC_Log::write('core', $e->getMessage(), OC_Log::ERROR);