The error below is prevent all mail from sending in Drupal since Bounce throws a SQL exception in bounce_determine_blocked_addresses. The message is being generated by the Drupal Subscription module so I am working on getting the message content to help with Debugging. Any information on how the data should look for the $destinations variable so I can put a quick fix in place until you get a change to look at this issue would be helpful.

From the error message it seems that the bounce_mail_remove_blocked_addresses is being called with a String, but it expects an Array.

Error:

[date] [host] [sitename]: http://[sitename]|1374512410|cron|127.0.0.1|http://[sitename]/index.php||5548||Exception: exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1' in includes/database/database.inc:2168 Stack trace: #0 includes/database/database.inc(2168): PDOStatement->execute(Array) #1 includes/database/database.inc(680): DatabaseStatementBase->execute(Array, Array) #2 includes/database/select.inc(1264): DatabaseConnection->query('SELECT b.mail A...', Array, Array) #3 sites/all/modules/bounce/bounce.module(752): SelectQuery->execute() #4 sites/all/modules/bounce/bounce.module(724): bounce_determine_blocked_addresses(Array) #5 sites/all/modules/bounce/bounce.module(786): bounce_mail_remove_blocked_addresses('') #6 includes/module.inc(1063): bounce_mail_alter(Array, NULL, NULL, NULL) #7 sites/all/modules/subscriptions/subscriptions_mail.cron.inc(222): drupal_alter('mail', Array) #8 sites/all/modules/subscriptions/subscriptions_mail.cron.inc(105): subscriptions_mail_digest_add_item(Array, 'subscriptions_m...', 'node-type-blog_...', Array, Object(stdClass)) #9 sites/all/modules/subscriptions/subscriptions_mail.module(34): _subscriptions_mail_cron() #10 [internal function]: subscriptions_mail_cron() #11 sites/all/modules/elysia_cron/elysia_cron.module(1090): call_user_func_array('subscriptions_m...', Array) #12 sites/all/modules/elysia_cron/elysia_cron.module(1011): elysia_cron_execute('subscriptions_m...') #13 sites/all/modules/elysia_cron/elysia_cron.drush.inc(28): elysia_cron_run(true) #14 [internal function]: drush_elysia_cron_run_wrapper() #15 /usr/local/drush4/includes/command.inc(131): call_user_func_array('drush_elysia_cr...', Array) #16 /usr/local/drush4/includes/command.inc(836): _drush_invoke_args('elysia_cron_run...', Array, 'elysia_cron') #17 [internal function]: drush_command() #18 /usr/local/drush4/includes/command.inc(236): call_user_func_array('drush_command', Array) #19 /usr/local/drush4/drush.php(101): drush_dispatch(Array) #20 /usr/local/drush4/drush.php(41): drush_main() #21 {main}

CommentFileSizeAuthor
#2 bounce.module.1.patch1.66 KB1point21
#1 bounce.module.patch1.4 KB1point21

Comments

1point21’s picture

StatusFileSize
new1.4 KB

Right now I running with the theory that some value which are sent to this function are format as an array like it expects. To combat this issue I have added any array check to the beginning of the function and a try / catch statement around the database queries. See the attached patch for more information.

1point21’s picture

StatusFileSize
new1.66 KB

In the attached patch I moved the array check to the bounce_mail_remove_blocked_addresses functions since it also expects an array. This is preferred over the previous patch.

exratione’s picture

It looks like you are making the right diagnosis. The error looks like Bounce is getting an empty email address passed to it in bounce_mail_alter(), so you wind up with an empty array passed into the SQL query IN clause in bounce_determine_blocked_addresses(), which causes it to fail.

Here on line 786 of bounce.module, it looks like $message['to'] is undefined or empty.

  $to = bounce_mail_remove_blocked_addresses($message['to']);

That's what I get for trusting input. I'll get onto a fix in the next couple of days.

You can probably circumvent the issue by checking for $message['to'] to be non-empty:

  if (empty($message['to'])) { return; }
  $to = bounce_mail_remove_blocked_addresses($message['to']);
exratione’s picture

I have committed an update f805873 that should fix the issue. I appreciate you bringing it to my attention. Please let me know if it solves the problem in your system, and I'll push it out as a release.

1point21’s picture

Thanks for the quick response! When I get a minute to put this on a server for testing I will reply back here with the results.

kmt333’s picture

Had the same issue and using the patch applied to the dev version fixed the issue for me.

exratione’s picture

Status: Active » Closed (fixed)

I've rolled this into a new release.

Kojo Unsui’s picture

Great, very useful patch !