Problem/Motivation

We have following for loop on class MailchimpSignupFormFormatter

    foreach ($items as $delta => $item) {
      if (!empty($item->_loaded)) {
        $entity = $item->entity;
      }

     // Other code
    }

Sometimes when $item->_loaded is empty, it tries to access the entity which is null.
We should continue if _loaded is empty.

Steps to reproduce

- Add a new signup form entity.
- Reference that on one block or paragraph field via entity reference field.
- Ensure that form is displayed when we view the content.
- Now delete the signup form from "admin/config/services/mailchimp/signup"
- Since deletion of signup form entity doesn't validate that signup is referenced anywhere on the page, it breaks the page where it is referenced.
- So in MailchimpSignupFormFormatter we should ensure that entity exists.

Proposed resolution

- Add a validation check on the formatter plugin.

Remaining tasks

- I've added an MR for the fix.
- Needs review

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork mailchimp-3565791

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

mohit_aghera created an issue. See original summary.

xenophyle made their first commit to this issue’s fork.

xenophyle’s picture

Status: Active » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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