Problem/Motivation

It is possible for a scenario to arise where the content entity ID or revision ID attached to a webform (and probably other config) does not correspond to an existing entity. This causes fatal errors on some pages that ultimately invoke Drupal\config_entity_revisions\ConfigEntityRevisionsControllerBase::createUpdateRevision(), such as the webform build page.

In my case I think this happened because of webform config referencing a revision being exported then imported on a remote environment where that revision did not exist. But it could happen in other situations as well, e.g. if a revision is deleted somehow.

It's also likely that this could cause a more subtle error where a webform would reference a revision not belonging to it.

Steps to reproduce

These steps to reproduce are to reproduce the error easily and differ from the config import way I mentioned above.

  1. Create a webform and add a revision
  2. Examine the webform's config and find the third_part_settings.webform_revisions key, e.g. with drush cget webform.webform.my_test_webform third_party_settings..webform_revisions.contentEntity_id.
  3. Delete the revision, e.g. with drush entity:delete config_entity_revisions 1 (but replace 1 with the revision ID if different)
  4. Try to visit the build tab for your webform - you will encounter a 500 error

The content of the error is:

Error: Call to a member function get() on null in Drupal\config_entity_revisions\ConfigEntityRevisionsControllerBase->createUpdateRevision() (line 206

Proposed resolution

This can be worked around by just adding a bit more defensive code to set the content and revision ID variables to NULL if the corresponding entity/revision can't be loaded. I'll attach an MR for that shortly.

With this workaround webforms still lose their revisions when imported. I think this is an edge case though and I don't see a simple way to resolve that. Seems like it would require syncing revisions between environments somehow which seems pretty out of scope for this module. Maybe you have a better idea though.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Dylan Donkersgoed created an issue. See original summary.

dylan donkersgoed’s picture

Status: Active » Needs review

Nigel Cunningham made their first commit to this issue’s fork.

nigelcunningham’s picture

Merged, thanks!

nigelcunningham’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.