Skip to content

Commit

Permalink
hotfix(backend): unexpected changed PHP behaviour caused spread malfu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
TyIsI committed Jan 12, 2025
1 parent ed3aa55 commit 96dfa5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions app/domain/Privilege.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ public static function Define() {
}

public static function findByCode($code) {
if (!self::checkCodeAccess(...$code)) {
if (!self::checkCodeAccess($code)) {
throw new UnauthorizedException();
}

$privs = Privilege::where(Where::Equal(Privilege::Schema()->Columns()->code, $code));

if (count($privs) > 0) {
if (!empty($privs)) {
return $privs[0];
}

return null;
}

public static function findByCodes(...$code) {
if (!self::checkCodeAccess(...$code)) {
public static function findByCodes(...$codes) {
if (!self::checkCodeAccess(...$codes)) {
throw new UnauthorizedException();
}

return Privilege::where(Where::In(Privilege::Schema()->Columns()->code, $code));
return Privilege::where(Where::In(Privilege::Schema()->Columns()->code, $codes));
}

private static function checkCodeAccess(...$codes) {
Expand All @@ -59,5 +59,6 @@ private static function checkCodeAccess(...$codes) {
}

public function validate(ValidationResults &$results) {
// Do nothing
}
}
2 changes: 1 addition & 1 deletion app/services/PrivilegeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function CountPrivileges($filters) {
public function CreatePrivilege($name, $code, $description, $icon, $enabled) {
$privs = Privilege::findByCode($code);

if (count($privs) != 0) {
if (!empty($privs)) {
throw new InvalidInputException('Privilege already exists with that code');
}

Expand Down

0 comments on commit 96dfa5b

Please sign in to comment.