diff options
author | Joas Schilling <coding@schilljs.com> | 2020-11-06 11:25:28 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-11-06 11:25:28 +0100 |
commit | 5fba0e562f1e9e7e53b28ce5e2a31346c70a7810 (patch) | |
tree | ea1230042e41ddec42a77d094d63358d72fe1f33 /apps/user_ldap/lib/Helper.php | |
parent | 2c6bbe783a6ab0f75f9ad85d66d9b4511a7543be (diff) | |
download | nextcloud-server-5fba0e562f1e9e7e53b28ce5e2a31346c70a7810.tar.gz nextcloud-server-5fba0e562f1e9e7e53b28ce5e2a31346c70a7810.zip |
Use query builder instead of OC_DB in user_ldap
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/user_ldap/lib/Helper.php')
-rw-r--r-- | apps/user_ldap/lib/Helper.php | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php index 86712534f40..2cd8b528d0b 100644 --- a/apps/user_ldap/lib/Helper.php +++ b/apps/user_ldap/lib/Helper.php @@ -35,23 +35,25 @@ namespace OCA\User_LDAP; use OC\Cache\CappedMemoryCache; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; +use OCP\IDBConnection; class Helper { /** @var IConfig */ private $config; + /** @var IDBConnection */ + private $connection; + /** @var CappedMemoryCache */ protected $sanitizeDnCache; - /** - * Helper constructor. - * - * @param IConfig $config - */ - public function __construct(IConfig $config) { + public function __construct(IConfig $config, + IDBConnection $connection) { $this->config = $config; + $this->connection = $connection; $this->sanitizeDnCache = new CappedMemoryCache(10000); } @@ -160,30 +162,22 @@ class Helper { return false; } - $saveOtherConfigurations = ''; - if (empty($prefix)) { - $saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\''; - } + $query = $this->connection->getQueryBuilder(); + $query->delete('appconfig') + ->where($query->expr()->eq('appid', $query->createNamedParameter('user_ldap'))) + ->andWhere($query->expr()->notIn('configkey', $query->createNamedParameter([ + 'enabled', + 'installed_version', + 'types', + 'bgjUpdateGroupsLastRun', + ]), IQueryBuilder::PARAM_STR_ARRAY)); - $query = \OC_DB::prepare(' - DELETE - FROM `*PREFIX*appconfig` - WHERE `configkey` LIKE ? - ' . $saveOtherConfigurations . ' - AND `appid` = \'user_ldap\' - AND `configkey` NOT IN (\'enabled\', \'installed_version\', \'types\', \'bgjUpdateGroupsLastRun\') - '); - $delRows = $query->execute([$prefix . '%']); - - if ($delRows === null) { - return false; - } - - if ($delRows === 0) { - return false; + if (empty($prefix)) { + $query->andWhere($query->expr()->notLike('configkey', $query->createNamedParameter('s%'))); } - return true; + $deletedRows = $query->execute(); + return $deletedRows !== 0; } /** |