Automated Drupal 10 compatibility fixes

Created on 15 June 2022, over 2 years ago
Updated 23 November 2023, 12 months ago

Problem/Motivation

Hello project maintainers,

This is an automated issue to help make this module compatible with Drupal 10.

To read more about this effort by the Drupal Association, please read: The project update bot is being refreshed to support Drupal 10 readiness of contributed projects โ†’

Patches will periodically be added to this issue that remove Drupal 10 deprecated API uses. To stop further patches from being posted, change the status to anything other than Active, Needs review, Needs work or Reviewed and tested by the community. Alternatively, you can remove the "ProjectUpdateBotD10" tag from the issue to stop the bot from posting updates.

The patches will be posted by the Project Update Bot โ†’ official user account. This account will not receive any issue credit contributions for itself or any company.

Proposed resolution

You have a few options for how to use this issue:

  1. Accept automated patches until this issue is closed

    If this issue is left open (status of Active, Needs review, Needs work or Reviewed and tested by the community) and the "ProjectUpdateBotD10" tag is left on this issue, new patches will be posted periodically if new deprecation fixes are needed.

    As the Drupal Rector project improves and is able to fix more deprecated API uses, the patches posted here will cover more of the deprecated API uses in the module.

    Patches and/or merge requests posted by others are ignored by the bot, and general human interactions in the issue do not stop the bot from posting updates, so feel free to use this issue to refine bot patches. The bot will still post new patches then if there is a change in the new generated patch compared to the patch that the bot posted last. Those changes are then up to humans to integrate.

  2. Leave open but stop new automated patches.

    If you want to use this issue as a starting point to remove deprecated API uses but then don't want new automated patches, remove the "ProjectUpdateBotD10" tag from the issue and use it like any other issue (the status does not matter then). If you want to receive automated patches again, add back the "ProjectUpdateBotD10" tag.

  3. Close it and don't use it

    If the maintainers of this project don't find this issue useful, they can close this issue (any status besides Active, Needs review, Needs work and Reviewed and tested by the community) and no more automated patches will be posted here.

    If the issue is reopened, then new automated patches will be posted.

    If you are using another issue(s) to work on Drupal 10 compatibility it would be very useful to other contributors to add those issues as "Related issues" when closing this issue.

Remaining tasks

Using the patches

  1. Apply the latest patch in the comments by Project Update Bot โ†’ or human contributors that made it better.
  2. Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
  3. Provide feedback about how the testing went. If you can improve the patch, post an updated patch here.

Providing feedback

If there are problems with one of the patches posted by the Project Update Bot โ†’ , such as it does not correctly replace a deprecation, you can file an issue in the Drupal Rector issue queue โ†’ . For other issues with the bot, for instance if the issue summary created by the bot is unclear, use the Project analysis issue queue โ†’ .

๐Ÿ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Hi, Iโ€™m working on this issue as part of Drupal Global Contribution Weekend 2023 #ContributionWeekend2023

  • @fjanate opened merge request.
  • @fjanate opened merge request.
  • Merge request !13Automated drupal 10 compatibility fixes โ†’ (Closed) created by fjanate
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom vince.rowe

    Hi there, is there any update on when the Drupal 10 updates will be complete and made usable?

    Many thanks

  • ๐Ÿ‡ช๐Ÿ‡ธSpain Carlos Romero

    Carlos Romero โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium Tim Lammar

    tim@lammar.be โ†’ made their first commit to this issueโ€™s fork.

  • This is an automated patch generated by Drupal Rector. Please see the issue summary for more details.

    It is important that any automated tests available are run with this patch and that you manually test this patch.

    Drupal 10 Compatibility

    According to the Upgrade Status module โ†’ , even with this patch, this module is not yet compatible with Drupal 10.

    Currently Drupal Rector, version 0.15.1, cannot fix all Drupal 10 compatibility problems.

    Therefore this patch does not update the info.yml file for Drupal 10 compatibility.

    Leaving this issue open, even after committing the current patch, will allow the Project Update Bot โ†’ to post additional Drupal 10 compatibility fixes as they become available in Drupal Rector.

    Debug info

    Bot run #12554

    This patch was created using these packages:

    1. mglaman/phpstan-drupal: 1.1.35
    2. palantirnet/drupal-rector: 0.15.1
  • ๐Ÿ‡จ๐Ÿ‡ณChina fishfree

    This is the patch agaist the dev branch:

    diff --git a/forms_steps.info.yml b/forms_steps.info.yml
    index a2f9bea..64d849a 100644
    --- a/forms_steps.info.yml
    +++ b/forms_steps.info.yml
    @@ -3,7 +3,7 @@ name: Forms Steps
    description: 'Provides Drupal multiple forms steps capability using forms views.'
    package: Forms
    core: 8.x
    -core_version_requirement: ^8 || ^9
    +core_version_requirement: ^8 || ^9 || ^10
    configure: entity.forms_steps.collection
    dependencies:
    - drupal:field
    diff --git a/forms_steps.module b/forms_steps.module
    index f2a29af..106117f 100644
    --- a/forms_steps.module
    +++ b/forms_steps.module
    @@ -165,7 +165,7 @@ function forms_steps_entity_predelete($entity) {
    // EntityQuery on Workflow entities.
    $query = \Drupal::entityQuery(Workflow::ENTITY_TYPE);
    $query->condition('entity_id', $entity_id);
    - $workflow_entity_ids = $query->execute();
    + $workflow_entity_ids = $query->accessCheck()->execute();
    if ($workflow_entity_ids) {
    // Loop through results so we can load the result as an entity to delete.
    foreach ($workflow_entity_ids as $workflow_entity_id) {
    diff --git a/src/Controller/FormsStepsController.php b/src/Controller/FormsStepsController.php
    index a89b9db..3b97c25 100644
    --- a/src/Controller/FormsStepsController.php
    +++ b/src/Controller/FormsStepsController.php
    @@ -147,6 +147,7 @@ class FormsStepsController extends ControllerBase {
    }
    else {
    $revision = $storage->getQuery()
    + ->accessCheck()
    ->condition($idKey, $_entity->entity_id->value)
    ->latestRevision()
    ->execute();
    diff --git a/src/Event/StepChangeEvent.php b/src/Event/StepChangeEvent.php
    index f686125..2ae2278 100644
    --- a/src/Event/StepChangeEvent.php
    +++ b/src/Event/StepChangeEvent.php
    @@ -7,7 +7,7 @@ namespace Drupal\forms_steps\Event;
    use Drupal\Core\Form\FormState;
    use Drupal\forms_steps\Entity\FormsSteps;
    use Drupal\forms_steps\Step;
    -use Drupal\Component\EventDispatcher\Event;
    +use Drupal\Contracts\EventDispatcher\Event;

    /**
    * Event that is fired when before we switch from one step to another.
    diff --git a/src/EventSubscriber/RouteSubscriber.php b/src/EventSubscriber/RouteSubscriber.php
    index dee9683..886620e 100644
    --- a/src/EventSubscriber/RouteSubscriber.php
    +++ b/src/EventSubscriber/RouteSubscriber.php
    @@ -102,6 +102,7 @@ class RouteSubscriber extends RouteSubscriberBase {
    $entity_ids = $this->entityTypeManager
    ->getStorage(FormsSteps::ENTITY_TYPE)
    ->getQuery()
    + ->accessCheck()
    ->execute();

    // Loads of all forms steps.
    diff --git a/tests/src/Functional/FormsStepsNavigationTest.php b/tests/src/Functional/FormsStepsNavigationTest.php
    index d504622..e6ef25b 100644
    --- a/tests/src/Functional/FormsStepsNavigationTest.php
    +++ b/tests/src/Functional/FormsStepsNavigationTest.php
    @@ -29,7 +29,7 @@ class FormsStepsNavigationTest extends BrowserTestBase {
    *
    * @var array
    */
    - public static $modules = [
    + protected static $modules = [
    'node',
    'entity_test',
    'field',
    @@ -40,7 +40,7 @@ class FormsStepsNavigationTest extends BrowserTestBase {
    /**
    * Setup the env for current test using trait methods.
    */
    - protected function setUp() {
    + protected function setUp(): void {
    parent::setUp();

    $this->formsStepsSetup();
    @@ -65,7 +65,7 @@ class FormsStepsNavigationTest extends BrowserTestBase {
    ->pageTextContains($this->data['forms_steps']['steps'][1]['label']);

    $value = 'This is an article Test Titre content';
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'title[0][value]' => $value,
    ], t('Save'));

    @@ -76,7 +76,7 @@ class FormsStepsNavigationTest extends BrowserTestBase {
    $this->assertSession()->pageTextContains($value);

    $value2 = 'This is an article Test Titre content 2';
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'title[0][value]' => $value2,
    ], t('Save'));

    @@ -86,7 +86,7 @@ class FormsStepsNavigationTest extends BrowserTestBase {
    $this->assertStringContainsStringIgnoringCase($this->data['forms_steps']['steps'][3]['url'], $this->getUrl());

    $value3 = 'This is a page Test Titre content';
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'title[0][value]' => $value3,
    ], t('Save'));

    @@ -99,19 +99,19 @@ class FormsStepsNavigationTest extends BrowserTestBase {
    $this->assertSession()->fieldValueEquals('title[0][value]', $value2);

    // Access step 3.
    - $this->drupalPostForm(NULL, [], 'Previous');
    + $this->submitForm([], 'Previous');
    $this->assertSession()
    ->pageTextContains($this->data['forms_steps']['steps'][3]['label']);
    $this->assertSession()->fieldValueEquals('title[0][value]', $value3);

    // Access step 2.
    - $this->drupalPostForm(NULL, [], 'Previous');
    + $this->submitForm([], 'Previous');
    $this->assertSession()
    ->pageTextContains($this->data['forms_steps']['steps'][2]['label']);
    $this->assertSession()->fieldValueEquals('title[0][value]', $value2);

    // Access step 1.
    - $this->drupalPostForm(NULL, [], 'Previous');
    + $this->submitForm([], 'Previous');
    $this->assertSession()
    ->pageTextContains($this->data['forms_steps']['steps'][1]['label']);
    $this->assertSession()->fieldValueEquals('title[0][value]', $value2);
    diff --git a/tests/src/Functional/FormsStepsTest.php b/tests/src/Functional/FormsStepsTest.php
    index 271dfef..89e4881 100644
    --- a/tests/src/Functional/FormsStepsTest.php
    +++ b/tests/src/Functional/FormsStepsTest.php
    @@ -29,7 +29,7 @@ class FormsStepsTest extends BrowserTestBase {
    *
    * @var array
    */
    - public static $modules = [
    + protected static $modules = [
    'node',
    'field',
    'field_ui',
    @@ -39,7 +39,7 @@ class FormsStepsTest extends BrowserTestBase {
    /**
    * Perform initial setup tasks that run before every test method.
    */
    - public function setUp() {
    + public function setUp(): void {
    parent::setUp();

    $this->formsStepsSetup();
    @@ -65,7 +65,7 @@ class FormsStepsTest extends BrowserTestBase {
    );
    $this->assertSession()->statusCodeEquals(200);
    // Add a form mode.
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'label' => $form_display_mode['label'],
    'id' => $form_display_mode['id'],
    ], t('Save'));
    @@ -103,7 +103,7 @@ class FormsStepsTest extends BrowserTestBase {

    // Activate Test Form Modes as a custom display mode.
    foreach ($this->data['form_display_modes'] as $form_display_mode) {
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    "display_modes_custom[${form_display_mode['id']}]" => $form_display_mode['id'],
    ], t('Save'));

    @@ -122,7 +122,7 @@ class FormsStepsTest extends BrowserTestBase {
    'form_mode_name' => $form_display_mode['id'],
    ]));
    $this->assertSession()->statusCodeEquals(200);
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'fields[title][region]' => 'content',
    'fields[body][region]' => 'hidden',
    'fields[status][region]' => 'hidden',
    @@ -136,7 +136,7 @@ class FormsStepsTest extends BrowserTestBase {
    $this->drupalGet(Url::fromRoute('entity.forms_steps.add_form'));
    $this->assertSession()->statusCodeEquals(200);
    // Test the creation of a form step.
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'label' => $this->data['forms_steps']['label'],
    'id' => $this->data['forms_steps']['id'],
    'description' => $this->data['forms_steps']['description'],
    @@ -157,7 +157,7 @@ class FormsStepsTest extends BrowserTestBase {
    $this->assertSession()->statusCodeEquals(200);

    // Test the creation of an add step.
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'label' => $step['label'],
    'id' => $step['id'],
    'target_form_mode' => $step['target_form_mode'],
    @@ -186,7 +186,7 @@ class FormsStepsTest extends BrowserTestBase {
    ->pageTextContains($this->data['forms_steps']['steps'][1]['label']);

    $value = 'This is a Test Titre content';
    - $this->drupalPostForm(NULL, [
    + $this->submitForm([
    'title[0][value]' => $value,
    ], t('Save'));

    diff --git a/tests/src/Kernel/KernelTestBase.php b/tests/src/Kernel/KernelTestBase.php
    index 8237219..addb062 100644
    --- a/tests/src/Kernel/KernelTestBase.php
    +++ b/tests/src/Kernel/KernelTestBase.php
    @@ -16,7 +16,7 @@ abstract class KernelTestBase {
    *
    * @var array
    */
    - public static $modules = ['forms_steps', 'user'];
    + protected static $modules = ['forms_steps', 'user'];

    /**
    * Setup the env for current test using trait methods.
    diff --git a/tests/src/Traits/FormsStepsTestTrait.php b/tests/src/Traits/FormsStepsTestTrait.php
    index 037adc9..0761151 100644
    --- a/tests/src/Traits/FormsStepsTestTrait.php
    +++ b/tests/src/Traits/FormsStepsTestTrait.php
    @@ -123,14 +123,10 @@ trait FormsStepsTestTrait {
    );

    // Add a form mode.
    - $this->drupalPostForm(
    - NULL,
    - [
    - 'label' => $form_display_mode['label'],
    - 'id' => $form_display_mode['id'],
    - ],
    - t('Save')
    - );
    + $this->submitForm([
    + 'label' => $form_display_mode['label'],
    + 'id' => $form_display_mode['id'],
    + ], t('Save'));

    Role::load($this->user->getRoles()[1])
    ->grantPermission('use node.' . $form_display_mode['id'] . ' form mode')
    @@ -162,13 +158,9 @@ trait FormsStepsTestTrait {

    // Activate Test Form Modes as a custom display mode.
    foreach ($this->data['form_display_modes'] as $form_display_mode) {
    - $this->drupalPostForm(
    - NULL,
    - [
    - "display_modes_custom[${form_display_mode['id']}]" => $form_display_mode['id'],
    - ],
    - t('Save')
    - );
    + $this->submitForm([
    + "display_modes_custom[${form_display_mode['id']}]" => $form_display_mode['id'],
    + ], t('Save'));
    }

    // Configure the visible fields.
    @@ -182,33 +174,25 @@ trait FormsStepsTestTrait {
    )
    );

    - $this->drupalPostForm(
    - NULL,
    - [
    - 'fields[title][region]' => 'content',
    - 'fields[body][region]' => 'hidden',
    - 'fields[status][region]' => 'hidden',
    - 'fields[uid][region]' => 'hidden',
    - 'fields[created][region]' => 'hidden',
    - 'fields[promote][region]' => 'hidden',
    - 'fields[sticky][region]' => 'hidden',
    - ],
    - t('Save')
    - );
    + $this->submitForm([
    + 'fields[title][region]' => 'content',
    + 'fields[body][region]' => 'hidden',
    + 'fields[status][region]' => 'hidden',
    + 'fields[uid][region]' => 'hidden',
    + 'fields[created][region]' => 'hidden',
    + 'fields[promote][region]' => 'hidden',
    + 'fields[sticky][region]' => 'hidden',
    + ], t('Save'));

    // Access forms steps add page.
    $this->drupalGet(Url::fromRoute('entity.forms_steps.add_form'));

    // Test the creation of a form step.
    - $this->drupalPostForm(
    - NULL,
    - [
    - 'label' => $this->data['forms_steps']['label'],
    - 'id' => $this->data['forms_steps']['id'],
    - 'description' => $this->data['forms_steps']['description'],
    - ],
    - t('Save')
    - );
    + $this->submitForm([
    + 'label' => $this->data['forms_steps']['label'],
    + 'id' => $this->data['forms_steps']['id'],
    + 'description' => $this->data['forms_steps']['description'],
    + ], t('Save'));

    // Perform steps creation.
    foreach ($this->data['forms_steps']['steps'] as $step) {
    @@ -223,35 +207,28 @@ trait FormsStepsTestTrait {
    );

    // Test the creation of an add step.
    - $this->drupalPostForm(
    - NULL,
    - [
    - 'label' => $step['label'],
    - 'id' => $step['id'],
    - 'target_form_mode' => $step['target_form_mode'],
    - 'target_entity_bundle' => $step['target_entity_bundle'],
    - 'target_entity_type' => $step['target_entity_type'],
    - 'url' => $step['url'],
    - ],
    - t('Save')
    - );
    + $this->submitForm([
    + 'label' => $step['label'],
    + 'id' => $step['id'],
    + 'target_form_mode' => $step['target_form_mode'],
    + 'target_entity_bundle' => $step['target_entity_bundle'],
    + 'target_entity_type' => $step['target_entity_type'],
    + 'url' => $step['url'],
    + ], t('Save'));

    if (!is_null($step['previous'])) {
    - // Update step with previous label.
    - $this->drupalPostForm(
    - Url::fromRoute(
    - 'entity.forms_steps.edit_step_form',
    - [
    - 'forms_steps' => $this->data['forms_steps']['id'],
    - 'forms_steps_step' => $step['id'],
    - ]
    - ),
    + $this->drupalGet(Url::fromRoute(
    + 'entity.forms_steps.edit_step_form',
    [
    - 'display_previous' => TRUE,
    - 'previous_label' => $step['previous'],
    - ],
    - t('Save')
    - );
    + 'forms_steps' => $this->data['forms_steps']['id'],
    + 'forms_steps_step' => $step['id'],
    + ]
    + ));
    + // Update step with previous label.
    + $this->submitForm([
    + 'display_previous' => TRUE,
    + 'previous_label' => $step['previous'],
    + ], t('Save'));
    }
    }
    }

  • First commit to issue fork.
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Composer require failure
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sumithra ramalingam

    Hi, I was using this module with D9.5 and now have asked for D10 upgradation. Someone could please help me on upgrading this module with D10 compatible.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nicoloye

    I'll review this issue current work status, but I won't be able to do so before DrupalCon.
    If anybody wants to step up before that feel free to do so.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States oadaeh

    I was working on this last week, but had to rebuild my local environment, due to various problems, so that delayed me a bit.
    Due to the fact that the MR is broken, I chose to manually create a patch file with all the relevant parts (and hopefully leaving out the brokenness). I did not at all investigate comment #17.
    The patch does apply for me, but only to 8.x-1.x-dev, due to some incompatible changes between it and 8.x-1.5.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Alina Basarabeanu

    The patch from #5 works as expected on forms_steps 8.x-1.x-dev and Drupal Version 9.5.11.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine artem_sylchuk Lutsk

    Patch from #21 applies clearly, however it includes the irrelevant part with automatted converting the ->link() to ->toLink()->toString() by rector.
    Fixed that and attached the interdiff.

    I tried to fix the MR, but it includes a lot of uneeded changes in commits history and it doesn't seem I can create a new branch for some reason.
    So I hope patch is fine too.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States oadaeh

    Thanks for that @artem_sylchuk.

    There are two more in src/Form/FormsStepsEditForm.php and one in src/Form/FormsStepsProgressStepEditForm.php.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine artem_sylchuk Lutsk

    Oh, my bad.
    Thanks for pointing that out @oadaeh!
    Updated the patch.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany spuky

    Upgrade Status is finding no Issues after applying the patch...

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States brooke_heaton

    I can confirm that patch #25 applies clean and upgrade_status no longer triggers an issue.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States chucksimply

    Confirming #25 works on 8.x-1.x-dev and Drupal Version 9.5.11. Can we commit to dev, and get a new official release?

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States chucksimply
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany spuky

    For any body using the patch here for their upgrade to D10 there is another issue patch you need to install

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany spuky
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany spuky

    For anybody using this patch for D10 upgrade you also need https://www.drupal.org/project/forms_steps/issues/3287673 ๐Ÿ“Œ Automated Drupal 10 compatibility fixes RTBC

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany spuky
  • Status changed to Fixed 12 months ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nicoloye

    Patch committed to the dev branch, preparing a new D10 release.
    Thanks everybody for the great work!

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

Production build 0.71.5 2024