As reported in a comment in the related issue, webform loops through each submission to clear it. This is potentially a problem if there are a lot of submissions. The loop is needed because there are hooks to be called. Otherwise the submissions could be deleted directly from the database with SQL.

I'm not sure what to do about this. We could use the batch api, which is a pain. We could create a drush command, which avoids the time limit but may still run out of memory. We could just delete the first N (which would be a hidden config variable), where N might be set pretty big initially (maybe 1000), and report if there are still more.

Comments

DanChadwick created an issue. See original summary.

peterx’s picture

How big is big?

You could process N and put the rest in a queue. Either cron, or a Poormanscron style module, could visit the queue.

If you are shutting down a form, closing the form in the first process and removing submissions in cron is not a problem because there is no time limit.

The problem is different when you want to clear existing submissions while leaving the form open for new submissions. For that situation, you would need a flag you can set to "delete" then let cron perform the delete.

danchadwick’s picture

Status: Active » Fixed

This patch uses the batch API for clearing submissions. It uses a batch size of the export batch size or 500, whichever is lower. This lower limit compensates for the extra load to delete submission.

Committed to 7.x-4.x.

danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Category: Bug report » Task
Status: Fixed » Patch (to be ported)

  • DanChadwick committed e985d25 on 7.x-4.x
    Issue #2563467 by DanChadwick: Fixed cannot clear a large number of...

  • fenstrat committed 325e7ae on 8.x-4.x
    Issue #2563467 by DanChadwick: Fixed cannot clear a large number of...
fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Category: Task » Bug report
Status: Patch (to be ported) » Fixed

Committed and pushed to 8.x-4.x.

Status: Fixed » Closed (fixed)

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