fix: Fix check of existing usernames in cli scripts (#5667)

`preg_grep` returns an empty array if the username matches no elements
from the usernames array.

Regression introduced in 7f9594b8c7

Reference: https://github.com/FreshRSS/FreshRSS/pull/5501
This commit is contained in:
berumuron 2023-09-22 11:41:49 +02:00 committed by GitHub
parent 2cb4f2e233
commit 662c9fcc2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -10,7 +10,7 @@ if (!FreshRSS_user_Controller::checkUsername($username)) {
}
$usernames = listUsers();
if (preg_grep("/^$username$/i", $usernames) !== false) {
if (preg_grep("/^$username$/i", $usernames)) {
fail('FreshRSS warning: username already exists “' . $username . '”', EXIT_CODE_ALREADY_EXISTS);
}

View File

@ -19,7 +19,7 @@ if (!FreshRSS_user_Controller::checkUsername($username)) {
}
$usernames = listUsers();
if (preg_grep("/^$username$/i", $usernames) === false) {
if (!preg_grep("/^$username$/i", $usernames)) {
fail('FreshRSS error: username not found “' . $username . '”');
}