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
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
Comment #7
xenophyle commentedThanks!