summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Goetz <markus@woboq.com>2013-10-05 19:18:18 +0200
committerMarkus Goetz <markus@woboq.com>2013-10-05 19:18:18 +0200
commite564a3a26627230951d86347fcf47aec40d1ca39 (patch)
treef1430d800dd16d893e7ed738d0882a49d5f60b38 /lib
parent7337b341106b6ae093b8d56c4d885b497db6e5aa (diff)
downloadnextcloud-server-e564a3a26627230951d86347fcf47aec40d1ca39.tar.gz
nextcloud-server-e564a3a26627230951d86347fcf47aec40d1ca39.zip
OC_App: Cache list of enabled apps
In my test here 1 SELECT instead of 5 (when doing a DAV request, probably similar for other requests)
Diffstat (limited to 'lib')
-rw-r--r--lib/private/app.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index 0ab1ee57f63..b4a71992178 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -165,10 +165,14 @@ class OC_App{
/**
* get all enabled apps
*/
+ private static $enabledAppsCache = array();
public static function getEnabledApps() {
if(!OC_Config::getValue('installed', false)) {
return array();
}
+ if(!empty(self::$enabledAppsCache)) {
+ return self::$enabledAppsCache;
+ }
$apps=array('files');
$sql = 'SELECT `appid` FROM `*PREFIX*appconfig`'
.' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'';
@@ -187,6 +191,7 @@ class OC_App{
$apps[]=$row['appid'];
}
}
+ self::$enabledAppsCache = $apps;
return $apps;
}
@@ -198,11 +203,11 @@ class OC_App{
* This function checks whether or not an app is enabled.
*/
public static function isEnabled( $app ) {
- if( 'files'==$app or ('yes' == OC_Appconfig::getValue( $app, 'enabled' ))) {
+ if('files' == $app) {
return true;
}
-
- return false;
+ $enabledApps = self::getEnabledApps();
+ return in_array($app, $enabledApps);
}
/**
@@ -214,6 +219,7 @@ class OC_App{
* This function set an app as enabled in appconfig.
*/
public static function enable( $app ) {
+ self::$enabledAppsCache = array(); // flush
if(!OC_Installer::isInstalled($app)) {
// check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
if(!is_numeric($app)) {
@@ -257,6 +263,7 @@ class OC_App{
* This function set an app as disabled in appconfig.
*/
public static function disable( $app ) {
+ self::$enabledAppsCache = array(); // flush
// check if app is a shipped app or not. if not delete
\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
OC_Appconfig::setValue( $app, 'enabled', 'no' );