There are two plugins taxonomy and role.
While creating a new category I chose only taxonomy.
Prepared my email.
When I click send button I received error.

PDOException: 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: SELECT u.uid FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid WHERE ur.rid IN (); Array ( ) in mass_contact_role_create_recipient_list() (line 42 of /var/www/registration/sites/all/modules/mass_mail/mass_contact/plugins/mass_contact_role.inc).

When I check the mass_contact.page.inc line 1025; I figured out that all plugins are running. There are no roles are selected and this gives error. Therefore, there should be a line

1- Either run a plugin if relevant data is selected
2- or do not run the query if array is empty.

CommentFileSizeAuthor
#4 mass_contact_taxonomy.0001.patch2.34 KBarkestra

Comments

oadaeh’s picture

Assigned: Unassigned » oadaeh

Thank you for pointing this issue out to me. I will take a look at it.

jotwede’s picture

Version: 7.x-1.x-dev » 7.x-1.0-alpha5
Priority: Normal » Major

Having the same problem with 7.x-1.0-alpha5 ...

arkestra’s picture

Version: 7.x-1.0-alpha5 » 7.x-1.0-alpha6

This is still present in alpha6, though it seems there is code to handle Taxonomy terms.

Query for Roles throws PDO error when role is not selected.

Taxonomy:

This line: (~L42 plugins/mass_contact_taxonomy.inc) $query->fieldCondition($field['field_name'], 'tid', $tids, 'IN');
adds a trailing INT to the end of the table name. Not sure why.

arkestra’s picture

StatusFileSize
new2.34 KB

I have fixed the issue.

  • plugins/mass_contact_taxonomy.inc - EntityFieldQuery() cannot handle "OR" logic, so I moved the query inside the if($field['module'] == 'taxonomy') loop. Each taxonomy ID is queried seperately.
  • plugins/mass_contact_role.inc - Added an extra Else @ line 37 to return an empty array if there are no Roles selected

I have a patch for the most recent Drupal 7 version, and would like to commit it to the repo, but the plugins folder is not present in the repository. Is this a change in the structure of the module, or an effect of having installed the module?

My patch is attached for reference.

oadaeh’s picture

Version: 7.x-1.0-alpha6 » 7.x-1.x-dev

@arkestra: you're making me nervous. Please don't commit anything, epecially if it's not on the correct version, and if you can't find the correct tree.

arkestra’s picture

Don't worry. Not gonna bother shoehorning it in if I can't get answers to questions.

oadaeh’s picture

@arkestra: I assumed you knew what you're doing, but maybe you're new to all this. You need to be operating in the git branch for the version of Mass Contact you're patching. In your case, that would be 7.x-1.x. That is found on this page: http://drupal.org/project/mass_contact/git-instructions (master hasn't been used by most people since the migration to git.)

The plugin code needs some serious review as there are quite a few flaws in it. I started doing that a few months ago, but got sidetracked by one thing and then another until I now it's been so long that need to start over.

Recreate your patch based on the 7.x-1.x git branch (which should have the plugins directory in it), and then I'll review it for submission.

oadaeh’s picture

Status: Fixed » Closed (fixed)

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

arkestra’s picture

@oadaeh Thanks for the tips. Was not not aware I was in the wrong branch.
Thanks for including the fix, will continue to monitor.