Undefined array key in Drupal\webform_revisions\WebformRevisionsSubmissionListBuilder->initialize()

Created on 23 August 2023, 10 months ago
Updated 22 November 2023, 7 months ago

Problem/Motivation

The error may be shown at the webform submissions listing page if the row for specific revision is rendered for the first time:

Undefined array key ... in Drupal\webform_revisions\WebformRevisionsSubmissionListBuilder->initialize()

Affected code:

      if (empty($webforms[$webformId])) {
        $webforms[$webformId] = [];
      }
      if ($webforms[$webformId][$webformRevisionId]) {
        continue;
      }

That is because the $webforms[$webformId][$webformRevisionId] may be not yet initialized.

Steps to reproduce

Open the /admin/structure/webform/submissions/manage page.

Proposed resolution

Just wrap the condition in !empty()

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @abramm
  • Issue was unassigned.
  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    Here's a tiny patch fixing this.

  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    Oops, here it is.

  • Status changed to Closed: outdated 7 months ago
  • πŸ‡¦πŸ‡ΊAustralia Nigel Cunningham Geelong

    Thanks for the patch but the fix was already added in f060e4cf.

    Regards,

    Nigel

  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    I don't think this was fixed in f060e4cf, in fact, f060e4cf has introduced the code which I'm fixing in the patch.

    From f060e4cf:

          if (empty($webforms[$webformId])) {
            $webforms[$webformId] = [];
          }
          if ($webforms[$webformId][$webformRevisionId]) {
            continue;
          }
    

    As you can see, the second if statement does not have !empty. This is in 2.x-dev branch.

    What's strange is there another commit (b8869ca96e338935d9557a12b4bc7de9624e4c41) in a different branch (2.0.x-dev) which adds the same code to the trait but with a different commit message and it does have !empty. Not sure what happened there, maybe some git rebase and force-push magic, but I'm happy to conclude this issue is not happening in 2.0.x-dev branch which is currently used to build releases. Likely the project where I faced this issue was using 2.x-dev branch.

  • πŸ‡¦πŸ‡ΊAustralia Nigel Cunningham Geelong

    Thanks for the reply.

    Ok, perhaps I made a mess somewhere there :) You can't force push to DO so I don't think that is what would have happened, but so long as we end up with usable code...

    Thanks again!

Production build 0.69.0 2024