Inside the webform_purge.module file, there are these lines of code:
- Line 35:
$query = db_query('SELECT * FROM {webform_submissions} WHERE webform_submissions.submitted < :purge_timestamp', array(':purge_timestamp' => $purge_timestamp)); - Line 200:
$query = db_query('SELECT nid FROM {webform_submissions} WHERE webform_submissions.nid = :nid', array(':nid' => $webform->nid)); - Line 204:
$query = db_query('SELECT MIN(webform_submissions.submitted) as oldest_date FROM {webform_submissions} WHERE webform_submissions.nid = :nid', array(':nid' => $webform->nid));
When I install the module and go to the admin page (admin/config/webform_purge/manage), I get the following error:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'webform_submissions.nid' in 'where clause': SELECT nid FROM {webform_submissions} WHERE webform_submissions.nid = :nid; Array ( [:nid] => 52465 ) in webform_purge_admin_settings_form() (regel 200 van /var/www/html/sites/all/modules/contrib/webform_purge/webform_purge.module)
Basically, you don't need to specify the name of the table in the WHERE-clause, because you already specified it in the FROM. When I remove those tablenames, you'll end up with the following code:
- Line 35:
$query = db_query('SELECT * FROM {webform_submissions} WHERE submitted < :purge_timestamp', array(':purge_timestamp' => $purge_timestamp)); - Line 200:
$query = db_query('SELECT nid FROM {webform_submissions} WHERE nid = :nid', array(':nid' => $webform->nid)); - Line 204:
$query = db_query('SELECT MIN(submitted) as oldest_date FROM {webform_submissions} WHERE nid = :nid', array(':nid' => $webform->nid));
Now, when I reload the admin form (admin/config/webform_purge/manage), the form will output correctly and no error is being showed.
I created a patch which can hopefully be applied to the dev version of this module, which I added as an attachment.
Comments
Comment #2
kevinkromjong commentedComment #3
fabianderijkComment #4
fabianderijkI've checked the patch and everything still works. Okay for me to add it to the module.
Comment #5
hctomWorks as expected and fixes the errors.
@bfry or any other maintainer: Is there any chance to get this merged? I'm currently developing another feature to limit the number of purged webform submissions (#2959844: Allow limiting the number of purged records), but this interferes with this patch as it would change things on a line that is already changed by this patch.
Comment #6
hctom... and when we are working on this, let's also remove the obsolete backticks from query code as well.
See attached patch and interdiff with the minor fix addons
Comment #7
jeroentTried the patch and it works fine. +1!
Comment #9
jeroentCommitted and pushed to 7.x-1.x. Thanks!