Skip to content

Commit 7ad98e8

Browse files
committed
Merge branch 'feature/handle-elements-not-present-in-submission'
2 parents 1e8ebfa + db875ed commit 7ad98e8

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
id: composer-cache
4040
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
4141
- name: Cache dependencies
42-
uses: actions/cache@v2
42+
uses: actions/cache@v4
4343
with:
4444
path: ${{ steps.composer-cache.outputs.dir }}
4545
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -70,7 +70,7 @@ jobs:
7070
id: composer-cache
7171
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
7272
- name: Cache dependencies
73-
uses: actions/cache@v2
73+
uses: actions/cache@v4
7474
with:
7575
path: ${{ steps.composer-cache.outputs.dir }}
7676
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -102,7 +102,7 @@ jobs:
102102
id: composer-cache
103103
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
104104
- name: Cache dependencies
105-
uses: actions/cache@v2
105+
uses: actions/cache@v4
106106
with:
107107
path: ${{ steps.composer-cache.outputs.dir }}
108108
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010

11+
## [1.0.1] - 2025-03-06
12+
13+
- Handled webform elements not present in submission data
14+
i.e. markup elements.
15+
- Handled `os2forms_person_lookup` element.
16+
1117
## [1.0.0] - 2025-02-28
1218

1319
- Version 1.0.0.
@@ -72,7 +78,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7278
- First version of the module
7379
- Added submodule to log user CUD events.
7480

75-
[Unreleased]: https://github.com/OS2web/os2web_audit/compare/1.0.0...HEAD
81+
[Unreleased]: https://github.com/OS2web/os2web_audit/compare/1.0.1...HEAD
82+
[1.0.1]: https://github.com/OS2web/os2web_audit/compare/1.0.0...1.0.1
7683
[1.0.0]: https://github.com/OS2web/os2web_audit/compare/0.2.2...1.0.0
7784
[0.2.2]: https://github.com/OS2web/os2web_audit/compare/0.2.1...0.2.2
7885
[0.2.1]: https://github.com/OS2web/os2web_audit/compare/0.2.0...0.2.1

modules/os2web_audit_entity/os2web_audit_entity.module

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,37 @@ function os2web_audit_entity_webform_post_load_data(mixed $submissions): void {
6464
$webform = $submission->getWebform();
6565
$elements = $webform->getElementsDecodedAndFlattened();
6666
foreach ($elements as $fieldName => $element) {
67-
if (str_contains(strtolower($element['#type']), 'cpr') || str_contains(strtolower($fieldName), 'cpr')) {
67+
if (
68+
str_contains(strtolower($element['#type']), 'cpr')
69+
|| str_contains(strtolower($element['#type']), 'os2forms_person_lookup')
70+
|| str_contains(strtolower($fieldName), 'cpr')) {
6871
$filterFields[] = $fieldName;
6972
}
7073
}
7174

7275
$submissionData = $submission->getData();
7376
if (!empty($filterFields)) {
7477
foreach ($filterFields as $field) {
75-
$cpr = $submissionData[$field];
78+
// Not all fields are present within submission data, i.e. markup.
79+
if (!isset($submissionData[$field])) {
80+
continue;
81+
}
82+
83+
$fieldValue = $submissionData[$field];
84+
85+
// Handles os2forms_person_lookup (cpr & name validation) element.
86+
if (is_array($fieldValue)) {
87+
// Example:
88+
// [
89+
// 'cpr_number' => 1234567890,
90+
// 'name' => Eksempel Eksempelsen,
91+
// ].
92+
$cpr = $fieldValue['cpr_number'] ?? NULL;
93+
}
94+
else {
95+
$cpr = $fieldValue;
96+
}
97+
7698
$personal .= sprintf(' CPR "%s" in field "%s".', $cpr ?: 'null', $field);
7799
}
78100
}

0 commit comments

Comments
 (0)