Skip to content

Commit

Permalink
Fix Person Role manager+sponsor field parsing beforeSave
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Feb 10, 2025
1 parent 531cd6a commit eb5c7e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/src/Model/Table/PersonRolesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,14 @@ public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayO
}

$re = '/^.*\(ID: (\d+)\)$/m';
if(!empty($data['sponsor_person_id'])) {
// The data coming from the API is an int while the data coming from the UI is a string. The
// latter is produced by the people picker
if(!empty($data['sponsor_person_id']) && !ctype_digit($data['sponsor_person_id'])) {
preg_match_all($re, $data['sponsor_person_id'], $matchesSponsor, PREG_SET_ORDER, 0);
$data['sponsor_person_id'] = $matchesSponsor[0][1];
}

if(!empty($data['manager_person_id'])) {
if(!empty($data['manager_person_id']) && !ctype_digit($data['manager_person_id'])) {
preg_match_all($re, $data['manager_person_id'], $matchesManager, PREG_SET_ORDER, 0);
$data['manager_person_id'] = $matchesManager[0][1];
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/VerificationsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function verifyCode(int $id, string $code): bool {
throw new \InvalidArgumentException(__d('error', 'Verifications.processed'));
}

if($verification->request_expiration_time->lt(FrozenTime::now())) {
if($verification->request_expiration_time->lessThan(FrozenTime::now())) {
$this->llog('debug', "Verification $id has expired");
throw new \InvalidArgumentException(__d('error', 'Verifications.expired'));
}
Expand Down

0 comments on commit eb5c7e4

Please sign in to comment.