I receive this error when I have uploaded a file to a newsletter node and attempt to send. Newsletters without files send fine.

Notice: Undefined variable: node in SimplenewsSourceNode->getAttachments() (line 780 of /home/content/90/8751990/html/sites/all/modules/simplenews/includes/simplenews.source.inc).

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7409 of /home/content/90/8751990/html/includes/common.inc).
CommentFileSizeAuthor
#3 fix_node_variable.patch622 bytesBerdir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Ah well, that happens when you don't really test now code :)

Support for attachments has been re-implemented from scratch for 7.x-1.x and, as you discovered, doesn't work yet.

Will look into it.

ComputerWolf’s picture

Found the issue.

On line 780 of simplenews.source.inc instead of:

if ($items = field_get_items('node', $node, $field_name)) {

it should be:

if ($items = field_get_items('node', $this->node, $field_name)) {

At least that fixes my issues and sends the files as a link.

Berdir’s picture

Status: Active » Needs review
FileSize
622 bytes

Confirmed, the attached patch fixes the bug.

Note that a bug in mimemail.module that prevented the files from being attached as actual attachments has been fixed just a few hours ago. See #1388786: mimemail_html_body fails to retrieve file's URI

I'm actually not happy how this currently works. E.g. even with the patch, the files are still listed in the body with the direct download URL. This is not desirable, but currently not easy to prevent except by creating your own theme function.

I do have a few ideas, including an "Attachment" formatter for these files. Maybe we'll also postpone this feature and re-implement better later on. Need to discuss this with the other maintainers.

Also no tests yet, these need a bit of work (add a file field, upload a file and so on), so postponing the tests until we've defined what behavior we actually want.

Berdir’s picture

Issue tags: +Needs tests

adding tag

Berdir’s picture

Title: Cannot send mail with attachment » Improve attachment handling
Category: bug » task
Priority: Major » Normal
Status: Needs review » Active

Commited the fix to prevent the fatal error.

Re-classifying this issue..

  • Berdir committed b907d34 on 8.x-1.x
    Issue #1387202 by Berdir, ComputerWolf: Fixed fatal error when sending...