diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-08 14:46:00 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-10 09:39:20 +0200 |
commit | 1ba2b7e5d4d787c64d07ddbf8bfa1efd74cccaa9 (patch) | |
tree | a9e5c5d1213fe4e715e5db7f3d0907caeaa2e3e2 /apps | |
parent | 3f40bb69f8c565a4c32f7452d8845936316377bb (diff) | |
download | nextcloud-server-1ba2b7e5d4d787c64d07ddbf8bfa1efd74cccaa9.tar.gz nextcloud-server-1ba2b7e5d4d787c64d07ddbf8bfa1efd74cccaa9.zip |
Do not query data that is already in the appconfig
This is already available. We better use a simple regex.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/user_ldap/lib/Helper.php | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php index 90807a3c526..1955e7b0eea 100644 --- a/apps/user_ldap/lib/Helper.php +++ b/apps/user_ldap/lib/Helper.php @@ -55,32 +55,21 @@ class Helper { public function getServerConfigurationPrefixes($activeConfigurations = false) { $referenceConfigkey = 'ldap_configuration_active'; - $sql = ' - SELECT DISTINCT `configkey` - FROM `*PREFIX*appconfig` - WHERE `appid` = \'user_ldap\' - AND `configkey` LIKE ? - '; - - if($activeConfigurations) { - if (\OC::$server->getConfig()->getSystemValue( 'dbtype', 'sqlite' ) === 'oci') { - //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison - $sql .= ' AND to_char(`configvalue`)=\'1\''; - } else { - $sql .= ' AND `configvalue` = \'1\''; + $config = \OC::$server->getConfig(); + + $keys = $config->getAppKeys('user_ldap'); + $prefixes = []; + foreach ($keys as $key) { + if (preg_match('/ldap_configuration_active$/S', $key) === 1) { + if ($activeConfigurations && $config->getAppValue('user_ldap', $key, '0') !== '1') { + continue; + } + + $len = strlen($key) - strlen($referenceConfigkey); + $prefixes[] = substr($key, 0, $len); } } - $stmt = \OCP\DB::prepare($sql); - - $serverConfigs = $stmt->execute(array('%'.$referenceConfigkey))->fetchAll(); - $prefixes = array(); - - foreach($serverConfigs as $serverConfig) { - $len = strlen($serverConfig['configkey']) - strlen($referenceConfigkey); - $prefixes[] = substr($serverConfig['configkey'], 0, $len); - } - return $prefixes; } |