Serialization of forms is a problem for #1863816: Allow plugins to have services injected so here's a patch that shifts entities (which are plugins) out of the recursive form array into the form_state arrays so that in a later step we can decide on how not to cache them (hardwire, move to form_state['no cache']['entity'], introduce form_state['no cache keys']). Small moves.

Comments

yched’s picture

I do share the worries about entity serialization, but entites are not plugins currently, right ?

yched’s picture

Also - field.module organizes its use of $form_state so that it can support fields on different entities in different parts of the form, so we can't put $entity directly at the top-level of $form_state.
This needs to go through field_form_get_state() / field_form_set_state().

Status: Needs review » Needs work

The last submitted patch, form_state_entity.patch, failed testing.

chx’s picture

StatusFileSize
new3.09 KB

Also #node

dawehner’s picture

Status: Needs work » Needs review

Let's run the testbot.

alansaviolobo queued 4: 1955874_4.patch for re-testing.

berdir’s picture

Issue summary: View changes
Issue tags: +Needs reroll

Those forms moved to classes, but it still seems like a good thing to do.

berdir’s picture

Issue tags: +Novice

Might be a good novice issue.

chx’s picture

Assigned: chx » Unassigned

Status: Needs review » Needs work

The last submitted patch, 4: 1955874_4.patch, failed testing.

mfernea’s picture

Issue tags: +Amsterdam2014

I'll have a look at this.

mfernea’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new954 bytes

Here is the rerolled patch.

Status: Needs review » Needs work

The last submitted patch, 12: drupal-better-form-serialization-1955874-12.patch, failed testing.

mfernea’s picture

Probably I should have used:
$form_state->setValue('entity', $node);
and
drupal_set_message($this->t('Updated book %title.', array('%title' => $form_state->getValue('entity')->label())));

I will try to test to make sure this is correct.

berdir’s picture

Yes, you can no longer use $form_state as an array. Instead, use $form_state->set()/get(). getValue()/setValue() is for form values.

mfernea’s picture

Status: Needs work » Needs review
StatusFileSize
new963 bytes

Here is the new patch. I'm using set() and get().

Status: Needs review » Needs work

The last submitted patch, 16: drupal-better-form-serialization-1955874-16.patch, failed testing.

Status: Needs work » Needs review
berdir’s picture

Status: Needs review » Needs work

Looks good!

As the title actually says #entity, I checked for that too and found one more instance in FieldEditForm.php, let's update that in a similar way.

mfernea’s picture

Status: Needs work » Needs review
StatusFileSize
new2.84 KB

Here is the updated patch.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, thanks.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

should we also be fixing #term in the OverviewTerms form? - This looks a bit more complex this it appears the terms already are in form state and the form is extended by Forum's Overview form.

alexandre.todorov’s picture

Status: Needs work » Needs review
StatusFileSize
new2.62 KB

$form_state->getValue('terms') is coming from validation of $form['terms'][$key] elements. So as suggested above I added $form_state set and get of 'terms'. Forum's Overview form also updated accordingly.

yched’s picture

@alexandre.todorov : your patch #23 does not seem to include the previous patch #20 ?

alexandre.todorov’s picture

Status: Needs review » Needs work
alexandre.todorov’s picture

Status: Needs work » Needs review
StatusFileSize
new3.56 KB

Updated #23 (taking into account rerolled #20)

ajits’s picture

Issue tags: -Novice

Looks like the 'novice' tasks was added in before the beta release. After checking the issue, I think this could mean changing some part of the API.
I am removing the tag as per https://www.drupal.org/core-mentoring/novice-tasks

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Version: 9.4.x-dev » 10.1.x-dev
Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

If still a valid task what's currently needed for 10.1?

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Just following up if still valid? If no follow up could close in 3 months

berdir’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Unsure. form serialization has changed, we now basically only start to persist them on the first ajax request. So I think that basically makes this a non-issue unless those forms use ajax.

Lets just close this unless someone has proof that this results in a measurable improvement?