Problem/Motivation

Deprecated function: Creation of dynamic property Drupal\autosave_form\Form\AutosaveFormBuilder::$_serviceId is deprecated in Drupal\Component\DependencyInjection\Container->createService() (line 285 of core/lib/Drupal/Component/DependencyInjection/Container.php).

Drupal\Component\DependencyInjection\Container->createService(Array, 'form_builder') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('form_builder') (Line: 640)

Steps to reproduce

Install it and view a page with the autosave form on PHP 8.2

Proposed resolution

Add

  /**
   * The service ID
   * 
   * @var string
   */
  public $_serviceId = 'autosave_form.form_builder';

to AutosaveFormBuilder.php

Remaining tasks

User interface changes

API changes

Data model changes

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

stevenlafl created an issue. See original summary.

keshavv’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed the patch and tested it. Its working prefect. moving to RTCB.

vipin.mittal18 made their first commit to this issue’s fork.

vipin.mittal18’s picture

Status: Reviewed & tested by the community » Needs work

As PHP 8.2 test cases failed, the status was changed to the correct one.

mlncn’s picture

Version: 8.x-1.4 » 8.x-1.x-dev
Status: Needs work » Reviewed & tested by the community

The test failures are not the result of this patch. Tests are failing on the unpatched dev branch already (and the released version of the module too).

The failures are different on the merge request because vipin.mittal18 added an absolutely necessary fix for the tests to run at all— changing the theme to Stark, rather than Classy which is not enabled. But that, and the general test failures, should probably be dealt with in a separate issue / patch.

The patch in stevenlafl's initial issue creation is correct and is ready to be committed as per keshav.k's review.

heddn’s picture

+1 on RTBC.

hchonov’s picture

But this issue shouldn't be occurring after https://www.drupal.org/node/3292540 or am I missing something here?

heddn’s picture

You would think, yes. Perhaps there is something else going on that still injects that? I didn't dig into why or what is setting that property, but in 10.1 and PHP 8.2, that property is still getting set on a regular basis, or basically every page. The warnings are quite noisy.

arunkumark’s picture

+1 RTBC. I have tested the patch with Drupal 10.0.5 it was working fine.

rollins’s picture

The provided patch also working ok for me.
PHP 8.2
autosave_form 1.4.0
Drupal core 9.5.9

santhosh@21’s picture

The reviewed patch also works for me
php - 8.2
drupal - 10.2
autosave_form - 1.4

adamevertsson’s picture

3 x RTBC. Could this be implemented in a stable release, I wonder?

finn lewis’s picture

Any chance of a release to include this?

mglaman’s picture

Status: Reviewed & tested by the community » Needs work

The issue is due to the decorated service.

  form_builder.autosave_form:
    public: false
    class: \Drupal\autosave_form\Form\AutosaveFormBuilder
    decorates: form_builder
    # The decorated autosave form builder should be the first applied as it
    # will not call further decorators, but directly override the core form
    # builder by extending from it and just calling the parent methods.
    decoration_priority: 10000
    arguments: ['@form_builder.autosave_form.inner', '@form_validator', '@form_submitter', '@form_cache', '@module_handler', '@event_dispatcher', '@request_stack', '@class_resolver', '@element_info', '@theme.manager', '@?csrf_token', '@autosave_form.entity_form_storage']
    # Workaround for serializing decorated services. Remove when either
    # https://www.drupal.org/project/drupal/issues/2896993 or
    # https://www.drupal.org/project/drupal/issues/2531564 are fixed.
    properties: { _serviceId: form_builder }

#2896993: Decorated services crash on serialization. was fixed in 9.4.x, and #2531564: Fix leaky and brittle container serialization solution in 9.5. We can remove the workaround and change core_version_requirement to core_version_requirement: ^9.5 || ^10

mglaman’s picture

Status: Needs work » Needs review
smulvih2’s picture

Status: Needs review » Reviewed & tested by the community

PR #12 worked for me, no longer seeing the deprecation error.

finn lewis’s picture

StatusFileSize
new1.95 KB

Adding a patch file version of the merge request #12

https://git.drupalcode.org/project/autosave_form/-/merge_requests/12#not...

baluertl’s picture

bramdriesen’s picture

We're using this patch for quite some time now on a multitude of projects in production. Would be nice to see this land! RTBC+1

hchonov’s picture

Merged. Thank you. This will be part of the 1.6 release.

hchonov’s picture

Status: Reviewed & tested by the community » Fixed
hchonov’s picture

bramdriesen’s picture

Don't forget to close the other MR so it won't linger around. https://git.drupalcode.org/project/autosave_form/-/merge_requests/9

hchonov’s picture

Thanks for the remainder, @BramDriesen :)

Status: Fixed » Closed (fixed)

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