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

kevinkromjong created an issue. See original summary.

kevinkromjong’s picture

fabianderijk’s picture

Status: Active » Needs review
fabianderijk’s picture

Status: Needs review » Reviewed & tested by the community

I've checked the patch and everything still works. Okay for me to add it to the module.

hctom’s picture

Works 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.

hctom’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.29 KB
new661 bytes

... 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

jeroent’s picture

Status: Needs review » Reviewed & tested by the community

Tried the patch and it works fine. +1!

  • JeroenT committed 9fa6ff0 on 7.x-1.x authored by kevinkromjong
    Issue #2937269 by hctom, kevinkromjong: Cannot load admin form because...
jeroent’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x-1.x. Thanks!

Status: Fixed » Closed (fixed)

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