The webform_get_submissions function in webform_submission.inc appears to be have been broken with the addition of a new parameter. This function sets up a parameterized query on the database. The problem is that the query construction is conditional based on the invocation with a zero or non-zero pagercount, but the query execution does not conditionally pass arguments...it always supplies nid, sids and uid. Thus, when pagercount is zero, the null sids variable will be consumed by the desired uid value thus breaking the query.
Suggested fix: I think the query execution must be conditional because either the sid or the uid could be zero so you probably need to do something like:
if ( $pager_count )
$res = db_query($query, $nid, $sids, $uid);
else
$res = db_query($query, $nid, $uid);
I don't know if this problem manifests itself in normal usage. I am calling the webform_get_submissions function in a custom module and this functionality broke when I updated from 6.x-2.3 to 6.x-2.4. I'm also not sure what the drupal module development conventions are. Is this function considered part of the API or was it not supposed to be used outside this module and that is why it exists in an .inc file? How does a module designate its API functions from its internal functions? Regardless, the logic appears incorrect.
Comment | File | Size | Author |
---|---|---|---|
#2 | webform_pagercount.patch | 649 bytes | quicksketch |
#1 | webform_pagercount.patch | 1.02 KB | quicksketch |
Comments
Comment #1
quicksketchProbably related to #360443: Empty results tab generates SQL error.
I've fixed this by rearranging the query slightly so that $sids are the last query parameter, so they'll be ignored if they're extra.
Comment #2
quicksketchAh, that's not going to work at all. Here's a version that uses the fix you suggested.
Comment #3
quicksketchTitle for posterity.
Comment #4
quicksketch