diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4762588..899403b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -39,7 +39,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -70,7 +70,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -102,7 +102,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9faa66d..b3a4a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.1] - 2025-03-06 + +- Handled webform elements not present in submission data + i.e. markup elements. +- Handled `os2forms_person_lookup` element. + ## [1.0.0] - 2025-02-28 - Version 1.0.0. @@ -72,7 +78,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - First version of the module - Added submodule to log user CUD events. -[Unreleased]: https://github.com/OS2web/os2web_audit/compare/1.0.0...HEAD +[Unreleased]: https://github.com/OS2web/os2web_audit/compare/1.0.1...HEAD +[1.0.1]: https://github.com/OS2web/os2web_audit/compare/1.0.0...1.0.1 [1.0.0]: https://github.com/OS2web/os2web_audit/compare/0.2.2...1.0.0 [0.2.2]: https://github.com/OS2web/os2web_audit/compare/0.2.1...0.2.2 [0.2.1]: https://github.com/OS2web/os2web_audit/compare/0.2.0...0.2.1 diff --git a/modules/os2web_audit_entity/os2web_audit_entity.module b/modules/os2web_audit_entity/os2web_audit_entity.module index 927bcde..1a78540 100644 --- a/modules/os2web_audit_entity/os2web_audit_entity.module +++ b/modules/os2web_audit_entity/os2web_audit_entity.module @@ -64,7 +64,10 @@ function os2web_audit_entity_webform_post_load_data(mixed $submissions): void { $webform = $submission->getWebform(); $elements = $webform->getElementsDecodedAndFlattened(); foreach ($elements as $fieldName => $element) { - if (str_contains(strtolower($element['#type']), 'cpr') || str_contains(strtolower($fieldName), 'cpr')) { + if ( + str_contains(strtolower($element['#type']), 'cpr') + || str_contains(strtolower($element['#type']), 'os2forms_person_lookup') + || str_contains(strtolower($fieldName), 'cpr')) { $filterFields[] = $fieldName; } } @@ -72,7 +75,26 @@ function os2web_audit_entity_webform_post_load_data(mixed $submissions): void { $submissionData = $submission->getData(); if (!empty($filterFields)) { foreach ($filterFields as $field) { - $cpr = $submissionData[$field]; + // Not all fields are present within submission data, i.e. markup. + if (!isset($submissionData[$field])) { + continue; + } + + $fieldValue = $submissionData[$field]; + + // Handles os2forms_person_lookup (cpr & name validation) element. + if (is_array($fieldValue)) { + // Example: + // [ + // 'cpr_number' => 1234567890, + // 'name' => Eksempel Eksempelsen, + // ]. + $cpr = $fieldValue['cpr_number'] ?? NULL; + } + else { + $cpr = $fieldValue; + } + $personal .= sprintf(' CPR "%s" in field "%s".', $cpr ?: 'null', $field); } }