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>
This commit is contained in:
Roeland Jago Douma 2016-10-08 14:46:00 +02:00
parent 3f40bb69f8
commit 1ba2b7e5d4
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
1 changed files with 11 additions and 22 deletions

View File

@ -55,30 +55,19 @@ class Helper {
public function getServerConfigurationPrefixes($activeConfigurations = false) { public function getServerConfigurationPrefixes($activeConfigurations = false) {
$referenceConfigkey = 'ldap_configuration_active'; $referenceConfigkey = 'ldap_configuration_active';
$sql = ' $config = \OC::$server->getConfig();
SELECT DISTINCT `configkey`
FROM `*PREFIX*appconfig`
WHERE `appid` = \'user_ldap\'
AND `configkey` LIKE ?
';
if($activeConfigurations) { $keys = $config->getAppKeys('user_ldap');
if (\OC::$server->getConfig()->getSystemValue( 'dbtype', 'sqlite' ) === 'oci') { $prefixes = [];
//FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison foreach ($keys as $key) {
$sql .= ' AND to_char(`configvalue`)=\'1\''; if (preg_match('/ldap_configuration_active$/S', $key) === 1) {
} else { if ($activeConfigurations && $config->getAppValue('user_ldap', $key, '0') !== '1') {
$sql .= ' AND `configvalue` = \'1\''; continue;
}
} }
$stmt = \OCP\DB::prepare($sql); $len = strlen($key) - strlen($referenceConfigkey);
$prefixes[] = substr($key, 0, $len);
$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; return $prefixes;