Skip to content

Commit

Permalink
Fix PermissionsTable for Cake 4.6 (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed May 7, 2025
1 parent 08637cb commit a7f2c2d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/src/Model/Table/PermissionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,20 @@ public function buildRules(RulesChecker $rules): RulesChecker {
*/

public function findForUser(string $username) {
return $this->find('list', ['keyField' => 'matchgrid_id', 'valueField' => 'permission'])
->where(['username' => $username])
->toArray();
// As of Cake 4.6 (or maybe 4.5) find('list') keyField can't have null values,
// so we manually assemble the result to an array and assign the platform a pseudo
// identifier of -1.
$perms = $this->find()
->where(['username' => $username])
->all();

$ret = [];

foreach($perms as $p) {
$ret[ $p->matchgrid_id ?? -1 ] = $p->permission;
}

return $ret;
}

/**
Expand Down

0 comments on commit a7f2c2d

Please sign in to comment.