Have a basic page content type where I've added a file upload filed from which I (as admin) can add files to the page content to generate download links for registered users. However, while the files seem to upload fine into a private directory (outside the web root) and generate links on the page okay, when I click the page link to the file I get the following error:
PDOException: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: integer = text LINE 1: ... f INNER JOIN webform_submitted_data wsd ON f.fid = wsd.data... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.: SELECT ws.uid, f.* FROM {file_managed} f INNER JOIN {webform_submitted_data} wsd ON f.fid = wsd.data INNER JOIN {webform_submissions} ws ON ws.sid = wsd.sid WHERE f.uri = :uri; Array ( [uri] => private://Program_RC1_0.exe ) in webform_file_download() (line 807 of /var/www/drupal-7.0/sites/all/modules/webform/webform.module).
I am not sure if this issue is related to the webform module but the Basic Page with the download link is accessed through a webform where the form settings allow me to redirect to this Basic Page through the custom URL field that redirects upon successful completion of the form. Also, the webform module is mentioned in the error message.
As a note when I upload the file it is called Program_RC1.exe but it gets changed to Program_RC1_0.exe each time.
I have no real idea where to check whats wrong here but any help would be much appreciated and if it is unrelated to the webform module my apologies for raising this issue here.
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 1057252.patch | 2.86 KB | chx |
| #5 | 1057252.patch | 2.86 KB | chx |
Comments
Comment #1
quicksketchThanks for the report. This sounds like a bug to me. The problem that is being reported is that we're trying to do a JOIN on "text" column in the webform_submitted_data table but it's an "integer" column in the file table. I haven't seen this issue myself, sounds like it might be database-system specific. What database and version are you using (i.e. MySQL 5.2.11)?
Also note that you can work-around this problem by using public files by default under the "File system" settings. You can still specify per-field private/public settings within CCK and most other systems, but Webform currently simply uses the site-wide default.
Comment #2
diplonics commentedThanks for the reply. The DB is PostgreSQL 8.4.6. Have upgraded the module to 3.8 because of the confirmation page redirection message problem so error has changed lines as below.
PDOException: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: integer = text LINE 1: ... f INNER JOIN webform_submitted_data wsd ON f.fid = wsd.data... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.: SELECT ws.uid, f.* FROM {file_managed} f INNER JOIN {webform_submitted_data} wsd ON f.fid = wsd.data INNER JOIN {webform_submissions} ws ON ws.sid = wsd.sid WHERE f.uri = :uri; Array ( [uri] => private://Program_RC1_0.exe ) in webform_file_download() (line 854 of /var/www/drupal-7.0/sites/all/modules/webform/webform.module).Have done as you suggested and the download file is now public, so am getting around this but it is not ideal. Had previously tried messing with the code and sql in webform.module as below but this didn't help solve the problem of keeping the file private.
I tried changing the sql as below to no avail, not even an error message. I also tried hardcoding the return array as below with the same lack of success.
Anyway, if I can offer any more info just ask or test/implement suggested fixes I can.
Thanks again.
Comment #3
quicksketchI'm pretty sure this problem is PostGres-specific (or possibly just MySQL-unspecific(?)). MySQL will easily let you join from a TEXT column into an INT column. The only solution that we'll actually be able to use here to make this database-agnostic would be to do multiple queries instead of a JOIN between the two tables.
Comment #4
quicksketchAlso reported as an issue with Oracle in #1226214: PDO Error when exporting to Excel and results->table (Oracle).
Comment #5
chx commentedTrying to compare an integer to a text column while on MySQL limps along it is not indexable. So this needs to be denormalized and badly.
Comment #6
chx commentedEdit: #1283456: webform_file_download query does not check that file is owned by Webform has been enrolled into this patch.
Comment #7
chx commentedLess broken :)
Comment #8
quicksketchThis seems like an adequate (if odd) solution, but it would require and update hook to migrate the existing data (which could be significant). I've committed #1283456: webform_file_download query does not check that file is owned by Webform separately.
Comment #9
quicksketchComment #10
chx commentedLike the included webform_update_7314 ?
Comment #11
quicksketchOh, I'm crazy. Okay udpate function in place. I'll need to double-check that CAST() is going to be acceptable to PostGres, since that's what we were originally trying to fix here.
Comment #12
chx commentedThat's why we have a parameter there.
Comment #13
quicksketchLet's take the approach from #289919: Provide AJAX-based file uploads/Progress Bar for uploads instead, which switches Webform to using the file_usage table for checking private downloads. It's much more robust anyway as it (finally) allows users access to their own files. Right now "access own webform submissions" permission won't allow users to view their own private webform files. That patch solves both issues.
Comment #14
dema502 commentedSorry my fault