diff options
author | brantje <brantje@gmail.com> | 2016-10-15 23:34:45 +0300 |
---|---|---|
committer | brantje <brantje@gmail.com> | 2016-10-15 23:34:45 +0300 |
commit | 11f427904c0844380059abca964a5b3eaa778dce (patch) | |
tree | a3a20b03f90053fa0d9d013e080dd13d45f064db /lib | |
parent | ce49cae86e7f6c114f8e17816b719c6b8f3cdfe6 (diff) |
Fix getRandomCredentialByVaultId for sqllite
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Db/CredentialMapper.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Db/CredentialMapper.php b/lib/Db/CredentialMapper.php index 060940a0..27646cbc 100644 --- a/lib/Db/CredentialMapper.php +++ b/lib/Db/CredentialMapper.php @@ -39,8 +39,11 @@ class CredentialMapper extends Mapper { */ public function getRandomCredentialByVaultId($vault_id, $user_id) { $sql = 'SELECT * FROM `*PREFIX*passman_credentials` ' . - 'WHERE `user_id` = ? and vault_id = ? AND shared_key is NULL ORDER BY RAND() LIMIT 1'; - return $this->findEntities($sql, [$user_id, $vault_id]); + 'WHERE `user_id` = ? and vault_id = ? AND shared_key is NULL'; + $entities = $this->findEntities($sql, [$user_id, $vault_id]); + $count = count($entities); + $entities = array_splice($entities, rand(0, $count), 1); + return $entities; } /** |