Previewing a node with a Payment form field causes an exception.

Exception: Serialization of 'Closure' is not allowed in serialize() (line 14 of core/lib/Drupal/Component/Serialization/PhpSerialize.php).

Steps to reproduce

  1. Enable Payment form +dependecies
  2. add the payment form field to any entity form
  3. create or edit an entity with that field
  4. click Preview button

Expected result

A preview of the content.

Actual result

The website encountered an unexpected error. Please try again later.

Exception: Serialization of 'Closure' is not allowed in serialize() (line 14 of core/lib/Drupal/Component/Serialization/PhpSerialize.php).

Proposed solution

The preview function tries to serialize the form state. Anonymous functions can't get serialized. The payment form module uses two anonymous functions for an element validate and a submit function.

I provided a patch which fixes these problems.

Important

In case the preview function still does not work after applying the patch check this issue: https://www.drupal.org/node/2325463

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ayrmax created an issue. See original summary.

Ayrmax’s picture

Priority: Normal » Major
Status: Active » Needs review
Ayrmax’s picture

Issue summary: View changes
Berdir’s picture

+++ b/src/Element/PaymentLineItemsInput.php
@@ -232,6 +221,24 @@ public function process(array $element, FormStateInterface $form_state, array $f
 
+  public function lineItemsValidate(array &$element, FormStateInterface $form_state, array &$form) {
+    $plugin_id = $this->getPluginId();

needs at least some basic documentation on those new methods.

Status: Needs review » Needs work

The last submitted patch, fix_preview.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.