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:
parent
3f40bb69f8
commit
1ba2b7e5d4
|
@ -55,32 +55,21 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$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;
|
return $prefixes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue