Bläddra i källkod

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
berumuron 2 år sedan
förälder
incheckning
662c9fcc2f
2 ändrade filer med 2 tillägg och 2 borttagningar
  1. 1 1
      cli/create-user.php
  2. 1 1
      cli/delete-user.php

+ 1 - 1
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);
 }
 

+ 1 - 1
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 . '”');
 }