Hello,

I am having the subscriptions module send notifications using cron and also testing held posts before sending. Occasionally cron will stop running, as reported in the drupal logs as 'Previous cron did not finish', and if I manually go to example.com/cron.php I get the following error:

Fatal error: Cannot use object of type stdClass as array in /home/clients/ymb/public_html/sandbox/modules/subscriptions/subscriptions.module on line 439

The error is caused because $content in the function subscriptions_testpost() is not being unserialized into an array, I believe. But, I'm not sure how come this is happening.

Thanks.

Comments

arthurf’s picture

Status: Active » Postponed (maintainer needs more info)

Hi-

would you do me a favor and either let me know what your line 439 is or try out the cvs 4.7 branch code? I'm looking at what I think is the line your reporting is failing and either I'm looking at the wrong code or something wacky is going on.

thanks

coltrane’s picture

Thanks for getting back to me arthurf.

Line 439:

$result = db_query('SELECT pid, status FROM {comments} WHERE cid = %d', $content['cid']);

I've tried out the recent branch code and seen that there some checks in place for $content. So far I have not experienced this error but with the old code it wouldn't show up right away, which is odd. I had enabled cron and test held posts and it worked fine for a bit. I wasn't able to identify what post/comment caused it to break.

Thanks, I'll post follow up if I experience the error again.

coltrane’s picture

I found another error related to this and specifically associated with the new checks. The error occurred when a user was trying to make a comment on a post.

Fatal error: Cannot use object of type stdClass as array in /home/clients/ymb/public_html/modules/subscriptions/subscriptions.module on line 611

Line 611 is:

$uid =is_null($comment->uid) ? $comment['uid'] : $comment->uid;

The problem I think is that is_null() there can still evaluate true on an object, so what is better is:

$uid = is_array($comment) ? $comment['uid'] : $comment->uid;
bdragon’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No longer relevant, please test against 5.x-2.0 beta.