I installed yesterday's dev snapshot to work around #2780573, and since then file uploads on the form result in a fatal error.

The message it get is:
PHP message: Uncaught PHP Exception LogicException: "The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution." at /path/to/drupal/core/lib/Drupal/Core/Database/Connection.php line 1425" while reading response header from upstr

I'm wondering if there's some debug code in there somewhere or maybe something else.

My form definition is:

society:
  '#type': textfield
  '#title': Society
  '#description': 'Name of Society.'
  '#maxlength': '255'
  '#placeholder': 'eg Albany Historical Society'
  '#required': true
  '#autocomplete_existing': true
contact_information:
  '#type': container
  '#title': 'Contact Information'
  '#description': 'Details of person submitting news item.'
  name:
    '#type': textfield
    '#title': Name
    '#placeholder': 'eg John Smith'
    '#required': true
  email:
    '#type': email
    '#title': Email
    '#placeholder': 'eg user@example.org'
    '#required': true
  phone:
    '#type': tel
    '#title': Phone
    '#required': true
title:
  '#type': textfield
  '#title': Title
  '#description': 'A short description of the news article'
  '#title_display': before
  '#placeholder': 'eg Our society is hosting an exhibition on local history'
  '#required': true
news_article:
  '#type': text_format
  '#title': 'News Article'
  '#description': 'News item details'
  '#required': true
  '#format': restricted_html
  '#allowed_formats':
    restricted_html: restricted_html
  '#hide_help': 1
  '#attributes':
    class: clearfix
image:
  '#type': managed_file
  '#title': Image
  '#description': 'Select an image to associate with your article.'
  '#max_filesize': '2'
  '#file_extensions': 'gif jpg png pdf'
captcha:
  '#type': captcha

Comments

kehan created an issue. See original summary.

kehan’s picture

I just checked both dev and 8.x-1.0-beta12 affected by this.

jrockowitz’s picture

Assigned: Unassigned » jrockowitz
Priority: Normal » Critical
Issue summary: View changes
StatusFileSize
new537.75 KB

Yep, I am familiar with this type of issue.

Here is the exact error message.

A fatal error occurred: The container was serialized.

I think the same issue is happening with #2782083: YAML Form disables ajax usage on media entity field.

Below is a screenshot confirming that I can duplicate the issue when I click remove on /yamlform/example_elements/test

jrockowitz’s picture

I am going to fix this ASAP and push a new release.

  • jrockowitz committed d42d0e0 on 8.x-1.x
    Issue #2782989: Uncaught PHP Exception LogicException in recent version
    
jrockowitz’s picture

This regression was caused by the below code in \Drupal\yamlform\Plugin\YamlFormElement\TextFormat which was part of #2771749: Support text_format's allowed formats

  /**
   * {@inheritdoc}
   */
  public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
    parent::prepare($element, $yamlform_submission);
    $element['#after_build'] = [[$this, 'afterBuild']];
  }

The $this reference in #afterBuild serialized the TextFormat YamlFormElement plugin.

Changing the afterBuild callback to use a static method solves the problem...

  /**
   * {@inheritdoc}
   */
  public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
    parent::prepare($element, $yamlform_submission);
    $element['#after_build'] = [[get_class($this), 'afterBuild']];
  }

This regression was introduction on July 23, 2016 and included in the 8.x-1.0-beta10 release

jrockowitz’s picture

Status: Active » Fixed

Since this issue was critical and very easy to fix and document. I push a new release.

@kehan Please confirm that your form is working as expected.

https://www.drupal.org/project/yamlform/releases/8.x-1.0-beta13

Status: Fixed » Closed (fixed)

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