Skip to content

Commit

Permalink
Avoided accessing non-initialized property
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Dec 10, 2024
1 parent 8410760 commit 5eca594
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/os2forms_nemid/src/Service/FormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,15 @@ public function retrieveCprLookupResult(FormStateInterface $form_state) {
$authProviderPlugin = $this->getAuthProvider($form_state);

$userCpr = $authProviderPlugin->fetchValue('cpr');
$lookedUpCpr = $cprLookupResult->getCpr();

$this->auditLogger->info('DataLookup', 'User with cpr ' . $userCpr . ' looked up cpr ' . $lookedUpCpr);
$lookedUpCpr = $cprLookupResult->getFieldValue('cpr');

// Current method is called whenever the webform is rendered.
// As a result, it is also called in situations where both
// userCpr and lookedUpCpr does not make sense, e.g.
// adding an element to a webform.
if ($userCpr && $lookedUpCpr) {
$this->auditLogger->info('DataLookup', 'User with cpr ' . $userCpr . ' looked up cpr ' . $lookedUpCpr);
}

return $cprLookupResult;
}
Expand Down

0 comments on commit 5eca594

Please sign in to comment.