A different form class is swapped for the 'install_configure_form' step.
That class uses a different form_id (config_installer_site_configure_form)

This breaks the drush site-install --account-name=* --account-pass=* --account-mail=* options, since drush takes those values and assigns these as values in $settings['install_configure_form.account.*'] (see drush_core_site_install_version() in drush/commands/core/drupal/site_install.inc), so that the installer task runner assigns the values to the form (by form ID).

So a CLI install command for the config_installer profile reads :

drush si config_installer -y --notify --account-name=admin --account-pass=admin \
  config_installer_site_configure_form.account.name=admin \
  config_installer_site_configure_form.account.pass.pass1=admin \
  config_installer_site_configure_form.account.pass.pass2=admin \
  config_installer_site_configure_form.account.mail=foo@bar.bz

(--account-name and --account-pass are inactive, but still need to be specified so that the message printed at the end of the install is accurate)

Is there any way config_installer's SiteConfigureForm could keep the same 'install_configure_form' form ID, so that the native --account-* args still work with drush si ?

Comments

yched’s picture

Issue summary: View changes
webflo’s picture

We could call $account_pass = drush_get_option('account-pass', drush_generate_password()); and $account_name = drush_get_option('account-name', 'admin'); inside of config_installer's SiteConfigureForm.

yched’s picture

@webflo : well, calling drush functions that fetch drush context from within an install profile is kind of hackish... 'drush site-install' has dedicated mechanisms to pass values to the installation forms.

Maybe instead of declaring its own separate form, config_installer should alter the existing one, so that the form_id stays the same ?

alexpott’s picture

When doing a site-install with Drush the config_installer is not treated like a real module so it would not be able to implement form alters :(. What is weird about this is that it is treated like a real module when doing an interactive install - see the fix for the config import batch steps in #2512700: Profiles are causing a problem whilst installing modules.

I think the best we can do here is either #2 which is hacky but with a function_exists() will work nicely or just add documentation on how to do it properly.

yched’s picture

form_alters : I thought that was how other profiles did it ? config_installer switching a different form / form_id seems pretty rare ?

But yeah, #2 is probably good enough if it does the job.

I guess the underlying issue is that our whole install process, including in drush, is still form-based rather than API-based. So passing values from drush site-install currently means passing values to a specific form with a specific form_id, which then can vary depending on the profile being installed.

nlisgo’s picture

Just supplying a patch for the approach in #2 that is working for me. The profile is working great for me.

jcnventura’s picture

Status: Active » Needs review

#6 worked fine for me. I'd mark it RTBC, had nlisgo marked it for review already.

jcnventura’s picture

Title: druh site-install --account-* options broken » drush site-install --account-* options broken
Status: Needs review » Reviewed & tested by the community

OK. So it seems there's no tests.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Re #8 there are tests but install profile tests cannot be run on DrupalCI (they didn't run on pifr/pift either) and yep this patch broke the tests because #default_value does not work with password_confirm form fields - Drupal just breaks horribly.

With the patch in #6...

Test summary
------------

Drupal\config_installer\Tests\ConfigInstallerSyncTest          4 passes             8 exceptions
Drupal\config_installer\Tests\ConfigInstallerTarballTest       6 passes   3 fails  11 exceptions

With what I have committed...

Test summary
------------

Drupal\config_installer\Tests\ConfigInstallerSyncTest         38 passes
Drupal\config_installer\Tests\ConfigInstallerTarballTest      39 passes

  • alexpott committed de55e65 on 8.x-1.x authored by nlisgo
    Issue #2495935 by nlisgo, yched, alexpott: drush site-install --account...
jcnventura’s picture

Status: Fixed » Reviewed & tested by the community
StatusFileSize
new934 bytes

Just a (tiny) bug in your patch, which unfortunately makes it non-functional.

  • alexpott committed c2dd885 on 8.x-1.x authored by jcnventura
    Issue #2495935 followup by jcnventura: drush site-install --account-*...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Opps and thanks @jcnventura

netamorfose’s picture

I am experiencing an InstallerException.
I executed this exact command

../vendor/bin/drush si config_installer -y --account-name=admin --account-pass=admin \
config_installer_site_configure_form.account.name=admin \
config_installer_site_configure_form.account.pass.pass1=admin \
config_installer_site_configure_form.account.pass.pass2=admin \
config_installer_site_configure_form.account.mail=foo@bar.bz

Trying with the following combinations:
1) Core 8.0.0 with drush 8.0.0
2) Core 8.0.1 with drush 8.0.1

both results in the same error:

cd56e03b8298:/var/www/project/repo/web# ../vendor/bin/drush si config_installer -y --account-name=admin --account-pass=admin config_installer_site_configure_form.account.name=admin config_installer_site_configure_form.account.pass.pass1=admin config_installer_site_configure_form.account.pass.pass2=admin config_installer_site_configure_form.account.mail=foo@bar.bz
You are about to DROP all tables in your 'wfp_org_d8' database. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a while. Consider using the --notify global option.                                                                                                        [ok]
exception 'Drupal\Core\Installer\Exception\InstallerException' in /var/www/project/repo/web/core/includes/install.core.inc:899                                                                      [error]
Stack trace:
#0 /var/www/project/repo/web/core/includes/install.core.inc(570): install_get_form('Drupal\config_i...', Array)
#1 /var/www/project/repo/web/core/includes/install.core.inc(526): install_run_task(Array, Array)
#2 /var/www/project/repo/web/core/includes/install.core.inc(116): install_run_tasks(Array)
#3 /var/www/project/repo/vendor/drush/drush/includes/drush.inc(721): install_drupal(Object(Composer\Autoload\ClassLoader), Array)
#4 /var/www/project/repo/vendor/drush/drush/includes/drush.inc(706): drush_call_user_func_array('install_drupal', Array)
#5 /var/www/project/repo/vendor/drush/drush/commands/core/drupal/site_install.inc(78): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array)
#6 /var/www/project/repo/vendor/drush/drush/commands/core/site_install.drush.inc(289): drush_core_site_install_version('config_installe...', Array)
#7 [internal function]: drush_core_site_install('config_installe...', 'config_installe...', 'config_installe...', 'config_installe...', 'config_installe...')
#8 /var/www/project/repo/vendor/drush/drush/includes/command.inc(364): call_user_func_array('drush_core_site...', Array)
#9 /var/www/project/repo/vendor/drush/drush/includes/command.inc(215): _drush_invoke_hooks(Array, Array)
#10 [internal function]: drush_command('config_installe...', 'config_installe...', 'config_installe...', 'config_installe...', 'config_installe...')
#11 /var/www/project/repo/vendor/drush/drush/includes/command.inc(183): call_user_func_array('drush_command', Array)
#12 /var/www/project/repo/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(65): drush_dispatch(Array)
#13 /var/www/project/repo/vendor/drush/drush/includes/preflight.inc(64): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#14 /var/www/project/repo/vendor/drush/drush/drush.php(12): drush_main()
#15 {main}

But commenting this lines out http://cgit.drupalcode.org/config_installer/commit/?id=de55e65 it works.

alexpott’s picture

@netamorfose what happens if you do ../vendor/bin/drush si config_installer -y --account-name=admin --account-pass=admin with this change it shouldn't be necessary to pass anything specific for the config_installer_site_configure_form

andrewsuth’s picture

@alexpott thanks for the clarification. I can confirm that it works as you outlined in #16

Status: Fixed » Closed (fixed)

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