Our client was getting this error:
SELECT contact_id FROM civicrm_membership WHERE id = [nativecode=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]
On line 334 it calls _get_civicrm_contactid_by_memberid($params['membershipID']) even on contribution pages that don't have a membership block. I added a check that $params['membershipID'] exists (see patch). It looks like that's the only place the function is called. If it's a donation page I figure civievent discount doesn't have anything to track here anyway.
| Comment | File | Size | Author |
|---|---|---|---|
| check-member.patch | 714 bytes | nubeli |
Comments
Comment #1
dharmatech commentedNubeli, can you provide a little more info on the configuration of the contribution page and steps to reproduce the error?
Comment #2
nubeli commentedNot sure what else I can provide. I believe that if you use a contribution page and if you *don't* have any memberships assigned then it will throw this error when going through the payment. For instance, on a donation page with no membership form.
Comment #3
dharmatech commentedThanks, I'll see if I can duplicate.
Comment #4
dharmatech commentednubeli,
Maybe it's a bug in older versions of CiviCRM but I'm not able to duplicate this in 3.4.5. $params['contactID'] is always there, even if you're anonymous. The only time it's not there is when a 100% discount is applied to membership. Here's what I tried.
If you can figure out a way to duplicate this, please post and we can reopen the issue.
Comment #5
nubeli commentedI can't replicate the error now - at the time it seemed like an obvious fix. It may be true then that there always is a contactID except for when there is a 100% discount (which is where I originally came across problem). So I'll let it rest unless it rears its head again.
It would make sense, however, to check for the existence of $params['membershipID'] before using it in the sql statement in the function _get_civicrm_contactid_by_memberid - "SELECT contact_id FROM civicrm_membership WHERE id = ". $mid. It may be unlikely but there may be some unknown combination that would cause the error (as I was initially able to trigger but can't replicate).
Comment #6
dharmatech commentedYes, the next -dev release will include a check for $params['membershipID'].
Comment #7
ericdrogers commentedI am also getting this on 6.x-1.x-dev. Any news on updated version?
Comment #8
dharmatech commented@ericdrogers, don't change the status to active unless you also assign it to yourself and fix it. Aside from a "me too" comment, what additional information can you provide that might help resolve the issue? We were not able to duplicate previously and the OP even had problems recreating it. If you figure out how to reliably reproduce it, we can re-open and fix it.