Problem/Motivation

I'm developing a new translation type plugin to also support translation of menu links used in Organic Group menus. To also support config changes made on UI and on CLI (during config import), I'm updating the Babel string sources with a configuration subscriber, in which I create the necessary batch operations. This batch is also executed by Drush after config import, and also by Form API after Babel's settings form is saved.

The problem is, the form alter done by Babel TMGMT adds callbacks to the form array which are not serializable; this prevents Form API to store the batch, and leads to error.

Exception: Serialization of 'Closure' is not allowed in serialize() (line 119 of core/lib/Drupal/Core/Batch/BatchStorage.php).

Drupal\Core\Batch\BatchStorage->create() (Line: 107)
Drupal\Core\ProxyClass\Batch\BatchStorage->create() (Line: 807)
batch_process() (Line: 56)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 615)
Drupal\Core\Form\FormBuilder->processForm() (Line: 347)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 634)
Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
Fiber->start() (Line: 635)
…

Steps to reproduce

Try to update the sources by config subscribers if Babel TMGMT is on.

Proposed resolution

Replace anonymous callback functions added in Babel TMGMT with static functions.

Remaining tasks

Patch

User interface changes

Nothing.

API changes

Nothing.

Data model changes

Nothing.

Issue fork babel-3583826

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

huzooka created an issue. See original summary.

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Active » Needs review

Failures are preexisting.
I created #3583847: Drupal core 11.4: Fix BabelTmgmtIntegrationTest and make PHPStan check happy to address the ones happening on 11.4 (next minor).
This needs review.

alorenc’s picture

Assigned: Unassigned » alorenc
alorenc’s picture

Thanks — I was able to reproduce the issue, and the patch successfully resolved it.

alorenc’s picture

Assigned: alorenc » Unassigned
Status: Needs review » Reviewed & tested by the community