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:
- 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.
- 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.
- 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
- Apply the latest patch in the comments by Project Update Bot or human contributors that made it better.
- Thoroughly test the patch. These patches are automatically generated so they haven't been tested manually or automatically.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | interdiff_23_25.txt | 1.03 KB | artem_sylchuk |
| #25 | forms_steps-drupal-10-compability-fixes_3287673-25.patch | 13.56 KB | artem_sylchuk |
| #22 | Screenshot 2023-10-03 at 09.16.15.png | 21.05 KB | alina.basarabeanu |
| #21 | 3287673-21-drupal-10-compatibility-fixes.patch | 16.53 KB | oadaeh |
| #16 | forms_steps.1.x-dev.rector.patch | 13.52 KB | project update bot |
Issue fork forms_steps-3287673
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
Comment #2
project update bot commentedThis 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.12.0, cannot fix all Drupal 10 compatibility problems.
This patch does not update the
info.ymlfile 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
This patch was created using these packages:
Comment #3
project update bot commentedThis 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.13.0, cannot fix all Drupal 10 compatibility problems.
This patch does not update the
info.ymlfile 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
This patch was created using these packages:
Comment #4
project update bot commentedThis 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.13.1, cannot fix all Drupal 10 compatibility problems.
This patch does not update the
info.ymlfile 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
This patch was created using these packages:
Comment #5
project update bot commentedComment #6
fjanate commentedHi, I’m working on this issue as part of Drupal Global Contribution Weekend 2023 #ContributionWeekend2023
Comment #7
nicoloye commentedComment #13
vince.rowe commentedHi there, is there any update on when the Drupal 10 updates will be complete and made usable?
Many thanks
Comment #16
project update bot commentedThis 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.ymlfile 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
This patch was created using these packages:
Comment #17
fishfree commentedThis 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'));
}
}
}
Comment #19
sumithra ramalingam commentedHi, 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.
Comment #20
nicoloye commentedI'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.
Comment #21
oadaeh commentedI 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.
Comment #22
alina.basarabeanu commentedThe patch from #5 works as expected on forms_steps 8.x-1.x-dev and Drupal Version 9.5.11.
Comment #23
artem_sylchukPatch 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.
Comment #24
oadaeh commentedThanks for that @artem_sylchuk.
There are two more in src/Form/FormsStepsEditForm.php and one in src/Form/FormsStepsProgressStepEditForm.php.
Comment #25
artem_sylchukOh, my bad.
Thanks for pointing that out @oadaeh!
Updated the patch.
Comment #26
spuky commentedUpgrade Status is finding no Issues after applying the patch...
Comment #27
brooke_heaton commentedI can confirm that patch #25 applies clean and upgrade_status no longer triggers an issue.
Comment #28
chucksimply commentedConfirming #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?
Comment #29
chucksimply commentedComment #30
spuky commentedplease ignore wrong url
Comment #31
spuky commentedComment #32
spuky commentedFor anybody using this patch for D10 upgrade you also need https://www.drupal.org/project/forms_steps/issues/3377136
Comment #33
spuky commentedComment #35
nicoloye commentedPatch committed to the dev branch, preparing a new D10 release.
Thanks everybody for the great work!