Problem/Motivation

If a contrib driver sets database credentials fields to 'hidden' in the installation form, Installer tests fail because Mink cannot find the fields to be set.

Proposed resolution

\Drupal\Core\Test\FunctionalTestSetupTrait::installParameters() should get the correct form fields used by the driver before passing these into submitForm.

Remaining tasks

Rework patch

User interface changes

none

API changes

none

Data model changes

none

Comments

mondrake created an issue. See original summary.

mondrake’s picture

StatusFileSize
new1.45 KB
mondrake’s picture

Status: Active » Needs review

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mondrake’s picture

StatusFileSize
new1.46 KB

Reroll

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mondrake’s picture

daffie’s picture

Issue tags: +Needs tests

@mondrake: Is it possible to add testing for this?

mondrake’s picture

#8 not easily in core, you'd have to develop a fake db driver that actually installs :(

I'm using this patch in the TravisCI test builds of my experimental Doctrine DBAL driver, that instead of providing user/password fields in the install form, just provides a textbox to insert a Doctrine DBAL connection URL.

daffie’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

If we cannot create testing for this then it must be very good documentated. In the patch and linked to this issue. Can you add screenshots/browser output with what good wrong. We need to make very clear why the code change is needed and hopefully make sure that somebody does not undo the change by eccident.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

mondrake’s picture

StatusFileSize
new1.45 KB

Rerolled

daffie’s picture

Status: Needs work » Reviewed & tested by the community

I have found a way to test this patch. In #3128699: Testing issue for pgsql_fallback is work being done to make the PostgreSQL fallback driver testable with Drupal core. Part of the current patch is:

diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
index 5728e62bc4..5aab4e5205 100644
--- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
@@ -507,6 +507,7 @@ protected function installParameters() {
     $connection_info['default']['prefix'] = $connection_info['default']['prefix']['default'];
     unset($connection_info['default']['driver']);
     unset($connection_info['default']['namespace']);
+    unset($connection_info['default']['autoload']);
     unset($connection_info['default']['pdo']);
     unset($connection_info['default']['init_commands']);
     // Remove database connection info that is not used by SQLite.

When I remove this part of the patch the testbot fails with 69 extra fails. See #3112735-90: [IGNORE] testing issue.
When I then add the patch from this issue, all those extra failures are fixed. See #3112735-89: [IGNORE] testing issue.
For me this is "prove" that the patch works.

All the changes in the patch looks good to me.
For me it is RTBC.

@mondrake: Thank you for you work on this issue!

catch’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php
@@ -239,7 +240,21 @@ protected function setUpProfile() {
    */
   protected function setUpSettings() {
-    $edit = $this->translatePostValues($this->parameters['forms']['install_settings_form']);
+    $temp_edit = $this->translatePostValues($this->parameters['forms']['install_settings_form']);
+
+    // Ensure that the fields to be edited actually exist on the form.
+    $assert_session = $this->assertSession();
+    $edit = [];
+    foreach ($temp_edit as $name => $value) {
+      try {
+        $field = $assert_session->fieldExists($name);
+        $edit[$name] = $value;
+      }
+      catch (ElementNotFoundException $e) {
+        continue;
+      }
+    }
+
     $this->submitForm($edit, $this->translations['Save and continue']);
   }

$edit was used in drupal_get_form() (via $_POST['edit']) a long time ago, but it's not (or shouldn't be) in common usage any longer. Could we change both $edit and $temp_edit to something more descriptive? I tried to think of them and couldn't though...

catch’s picture

Maybe $form_values and $form_values_to_submit?

mondrake’s picture

Status: Needs review » Needs work
Issue tags: +Novice

Good suggestion in #16!

adityasingh’s picture

Status: Needs work » Needs review
StatusFileSize
new1.56 KB
new1.24 KB

Updated patch as suggested in #16.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I think this fix is being done in the wrong place. It feels as though \Drupal\Core\Test\FunctionalTestSetupTrait::installParameters() needs to get the correct params for the form. Perhaps we need to call \Drupal\Core\Database\Install\Tasks::getFormOptions() here and make sure we're doing the right thing. Or we need so new method on the db connection to get install settings.

But the current solution has the downside of hiding errors if installParameters() sets something up incorrectly.

mradcliffe’s picture

Issue summary: View changes

I performed Novice Triage on this issue. I am leaving the Novice tag on this issue because I think that the direction @alexpott provided in #20 should be sufficient to fix.

I changed the issue summary proposed resolution to reflect this.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

mondrake’s picture

Version: 9.5.x-dev » 10.0.x-dev
StatusFileSize
new1.54 KB

Rerolled

akashkumar07’s picture

Status: Needs work » Needs review
mondrake’s picture

Status: Needs review » Needs work

Still needs work for #20, the reroll did not address that

andregp’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.15 KB

I tried to address #20.
No interdiff as it's a completely different code (different file and approach).

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.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

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Last patch had some failures.

sahil.goyal’s picture

StatusFileSize
new1.53 KB
new548 bytes

For resolving such failure need to create a concrete subclass that extends the abstract Tasks class, and then instantiate the subclass instead of the abstract class directly. updating the patch and Interdiff along.

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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.