Merge pull request #2778 from Icinga/bugfix/adding-empty-user-backend-fails-2598

DbUserBackend: don't fail at validation if there aren't any active users
This commit is contained in:
Eric Lippmann 2017-03-28 09:14:55 +02:00
commit 7f42efa1c0
1 changed files with 1 additions and 6 deletions

View File

@ -285,12 +285,7 @@ class DbUserBackend extends DbRepository implements UserBackendInterface, Inspec
$insp = new Inspection('Db User Backend');
$insp->write($this->ds->inspect());
try {
$users = $this->select()->where('is_active', true)->count();
if ($users > 0) {
$insp->write(sprintf('%s active users', $users));
} else {
return $insp->error('0 active users', $users);
}
$insp->write(sprintf('%s active users', $this->select()->where('is_active', true)->count()));
} catch (Exception $e) {
$insp->error(sprintf('Query failed: %s', $e->getMessage()));
}