Problem

Adding a "FlowDrop Workflow" action to any field widget on a form that also contains a managed_file/file widget (e.g. /media/add/document) makes the form crash on file upload with:

  Exception: Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed
    in serialize() (line 14 of core/lib/Drupal/Component/Serialization/PhpSerialize.php).
    #3 core/lib/Drupal/Core/Form/FormCache.php(181):
       Drupal\Core\KeyValueStore\DatabaseStorageExpirable->setWithExpire()
    #5 core/lib/Drupal/Core/Form/FormBuilder.php(462):
       Drupal\Core\Form\FormBuilder->setCache()
    #6 core/lib/Drupal/Core/Form/FormBuilder.php(651):
       Drupal\Core\Form\FormBuilder->rebuildForm()

Root cause

FieldWidgetActionBase::actionButton() attaches '#ajax' => ['callback' => [$this, $this->getAjaxCallback()]] to the button it renders. $this is the FlowDropWorkflowAction plugin instance, which gets serialized into the form
cache on every form rebuild (e.g. managed_file's upload AJAX).

Two issues compound

1. FlowDropWorkflowAction does not use DependencySerializationTrait, so PHP recursively serializes every injected service (entity type manager, orchestrator, logger, …). Each of those transitively references the current
Request, which carries the UploadedFile for the in-progress upload.
2. Even after adding DependencySerializationTrait, one injected property still fails: protected LoggerChannelInterface $logger. It is built via logger.factory->get('flowdrop_field_widget_actions') and is not itself a
registered container service, so ReverseContainer::getId() returns NULL and the trait cannot reduce it. The trait leaves the LoggerChannel object intact, PHP serializes it, and its internal RequestStack drags UploadedFile
into the graph → crash.

Fix

In FlowDropWorkflowAction:

1. use DependencySerializationTrait.
2. Inject LoggerChannelFactoryInterface (the actual container service logger.factory) instead of a LoggerChannelInterface. Resolve the channel lazily via a getLogger() helper.

A secondary bug surfaced once the upload worked: FieldContentProcessor::extractSingleFieldItem() does not handle the managed_file widget's form-state shape (['fids' => [...]]), so file-field values silently disappear from
the extracted context.

Steps to reproduce

1. Install flowdrop_field_widget_actions.
2. On a Media document (or any bundle with both a file field and a text field) form display, enable the "FlowDrop Workflow" action on the text field.
3. Visit /media/add/document, attach a PDF/file → fatal.

AI Disclaimer

AI has been used to help crafting both the ticket description and the fix.
I have reviewed both before posting :)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

marcoscano created an issue. See original summary.

marcoscano’s picture

Issue summary: View changes
Status: Active » Needs review

gxleano made their first commit to this issue’s fork.

gxleano’s picture

Thank you very much Marcos, to point this out!

I have been testing locally, and everything seems to be working fine.

Workflow

Media Document Suggestion Workflow

Suggestions

FlowDrop FWA Suggestion

gxleano’s picture

Status: Needs review » Reviewed & tested by the community
gxleano’s picture

It will be part of the next release 1.0.1

gxleano’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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