From 662c9fcc2f5c6f2671b1b371c30990782a99b1a2 Mon Sep 17 00:00:00 2001 From: berumuron Date: Fri, 22 Sep 2023 11:41:49 +0200 Subject: 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 7f9594b8c7d7799f2e5f89328bd5981410db8cf0 Reference: https://github.com/FreshRSS/FreshRSS/pull/5501 --- cli/create-user.php | 2 +- cli/delete-user.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cli') diff --git a/cli/create-user.php b/cli/create-user.php index 1da7f580d..c6364371a 100755 --- a/cli/create-user.php +++ b/cli/create-user.php @@ -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); } diff --git a/cli/delete-user.php b/cli/delete-user.php index 7b05cbe7a..fbbb2eebb 100755 --- a/cli/delete-user.php +++ b/cli/delete-user.php @@ -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 . '”'); } -- cgit v1.2.3