Download & Extend

simplenews_send_source() results in PHP notices ("Trying to get property of non-object")

Project:Simplenews
Version:7.x-1.x-dev
Component:Code
Category:bug report
Priority:major
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I have a case of many notices per cron run.

The methods...
SimplenewsSourceNode->getLanguage() (multiple times)
SimplenewsSourceNode->getRecipient() and
SimplenewsSourceNode->setContext()
...all try to return properties of an invalid $source.

By investigating the code a little bit, I think all originate from simplenews_get_spool() which must be in my current setup be returning invalid sources.

My best guess is, there are subscriptions of deleted accounts. Cron likely tries to spool their newsletters. The mailing always fails, so they remain in the spooler. Just a guess!

Setting issue to major, because it accumulates and is capable on a site with many users to kill simplenews spooler (or even cron?) and flood watchdog.

A quick fix might be is to check the $source in simplenews_send_source() and - in case of an invalid object - assume success to proceed with the healthy spooler cleanup. This would not heal the original issue, but be helpful on affected production environments. I'd provide such a patch in case the issue doesn't get fixed contemporary.

Comments

#1

Status:active» needs review

Confirmed, this happens when a subscriber failed to load, because for example the user account has been deleted.

AttachmentSizeStatusTest resultOperations
missing-subscribers-1739312-1.patch2.16 KBIdlePASSED: [[SimpleTest]]: [MySQL] 1,863 pass(es).View details

#2

Status:needs review» fixed

Commited.

#3

I get these notices even with the latest dev when try to send a node that existed before Simplenews installation.
I have created separate issue : #1780134: Create newsletters for existing nodes.

#4

Status:fixed» closed (fixed)

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