Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeform: Purging Old Spam Submissions fails. #1666

Closed
bartdigitalpulse opened this issue Dec 2, 2024 · 2 comments · Fixed by #1679
Closed

Freeform: Purging Old Spam Submissions fails. #1666

bartdigitalpulse opened this issue Dec 2, 2024 · 2 comments · Fixed by #1679
Assignees
Labels
issue Something isn't working correctly

Comments

@bartdigitalpulse
Copy link

What happened?

Queue is filled with failed "Purging Old Spam Submissions" jobs. Checking the logs I see it fails when trying to remove the uploaded files:

Error: craft\services\Elements::deleteElementById(): Argument #1 ($elementId) must be of type int, string given
Location: /vendor/solspace/craft-freeform/packages/plugin/src/Bundles/Fields/Implementations/FileUpload/FileRemovalOnSubmissionDelete.php on line 32

When I check the submissions these are simple bot submissions with no uploaded file in the asset field. They probably managed to upload an empty string?

Adding a "check empty" and "is integer" before deleteElementById fixes the issue.

Example bot submission
5dxAB4xcoF

Errors and Stack Trace (if available)

#0 /vendor/solspace/craft-freeform/packages/plugin/src/Bundles/Fields/Implementations/FileUpload/FileRemovalOnSubmissionDelete.php(32): craft\services\Elements->deleteElementById()
#1 [internal function]: Solspace\Freeform\Bundles\Fields\Implementations\FileUpload\FileRemovalOnSubmissionDelete->removeSubmissionFiles()
#2 /vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#3 /vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger()
#4 /vendor/craftcms/cms/src/base/Element.php(5240): yii\base\Component->trigger()
#5 /vendor/craftcms/cms/src/services/Elements.php(2164): craft\base\Element->afterDelete()
#6 /vendor/solspace/craft-freeform/packages/plugin/src/Services/SubmissionsService.php(393): craft\services\Elements->deleteElement()
#7 /vendor/solspace/craft-freeform/packages/plugin/src/Jobs/PurgeSpamJob.php(14): Solspace\Freeform\Services\SubmissionsService->purgeSubmissions()
#8 /vendor/yiisoft/yii2-queue/src/Queue.php(243): Solspace\Freeform\Jobs\PurgeSpamJob->execute()
#9 /vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\queue\Queue->handleMessage()
#10 /vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\queue\cli\Queue->execute()
#11 [internal function]: yii\queue\cli\Command->actionExec()
#12 /vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#13 /vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#14 /vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#15 /vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction()
#16 /vendor/yiisoft/yii2/base/Module.php(552): craft\queue\Command->runAction()
#17 /vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#18 /vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#19 /vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#20 /vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest()
#21 /vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()
#22 /craft(13): yii\base\Application->run()
#23 {main}

How can we reproduce this?

  1. Spambot submission in a form with asset field
  2. Bot manages to submit empty string
  3. Set purge submissions by x days

Freeform Edition

Pro

Freeform Version

5.7.4

Craft Version

Craft Pro 4.13.3

When did this issue start?

Unsure

Previous Freeform Version

No response

@bartdigitalpulse bartdigitalpulse added the issue Something isn't working correctly label Dec 2, 2024
@kjmartens
Copy link
Contributor

Sorry for the delay and the trouble @bartdigitalpulse,

I will have a developer check into this shortly. 🙂

@kjmartens
Copy link
Contributor

This is now resolved in Freeform 5.8.2+ 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue Something isn't working correctly
Development

Successfully merging a pull request may close this issue.

3 participants