Skip to content
Snippets Groups Projects
Commit c5193b30 authored by catch's avatar catch
Browse files

Issue #3458167 by sokru, andypost, prashant.c, quietone: Add password option...

Issue #3458167 by sokru, andypost, prashant.c, quietone: Add password option to Drupal\Core\Command\InstallCommand
parent 0ba8488d
Branches
Tags
17 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #305153 passed with warnings
Pipeline: drupal

#305169

    Pipeline: drupal

    #305162

      Pipeline: drupal

      #305156

        ...@@ -50,6 +50,7 @@ protected function configure() { ...@@ -50,6 +50,7 @@ protected function configure() {
        ->setDescription('Installs a Drupal demo site. This is not meant for production and might be too simple for custom development. It is a quick and easy way to get Drupal running.') ->setDescription('Installs a Drupal demo site. This is not meant for production and might be too simple for custom development. It is a quick and easy way to get Drupal running.')
        ->addArgument('install-profile-or-recipe', InputArgument::OPTIONAL, 'Install profile or recipe directory from which to install the site.') ->addArgument('install-profile-or-recipe', InputArgument::OPTIONAL, 'Install profile or recipe directory from which to install the site.')
        ->addOption('langcode', NULL, InputOption::VALUE_OPTIONAL, 'The language to install the site in.', 'en') ->addOption('langcode', NULL, InputOption::VALUE_OPTIONAL, 'The language to install the site in.', 'en')
        ->addOption('password', NULL, InputOption::VALUE_OPTIONAL, 'The password to use for the site. Defaults to random password.')
        ->addOption('site-name', NULL, InputOption::VALUE_OPTIONAL, 'Set the site name.', 'Drupal') ->addOption('site-name', NULL, InputOption::VALUE_OPTIONAL, 'Set the site name.', 'Drupal')
        ->addUsage('demo_umami --langcode fr') ->addUsage('demo_umami --langcode fr')
        ->addUsage('standard --site-name QuickInstall') ->addUsage('standard --site-name QuickInstall')
        ...@@ -115,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ...@@ -115,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
        return 1; return 1;
        } }
        return $this->install($this->classLoader, $io, $install_profile ?? '', $input->getOption('langcode'), $this->getSitePath(), $input->getOption('site-name'), $recipe ?? ''); return $this->install($this->classLoader, $io, $install_profile ?? '', $input->getOption('langcode'), $this->getSitePath(), $input->getOption('site-name'), $recipe ?? '', $input->getOption('password'));
        } }
        /** /**
        ...@@ -154,6 +155,8 @@ protected function isDrupalInstalled() { ...@@ -154,6 +155,8 @@ protected function isDrupalInstalled() {
        * The site name. * The site name.
        * @param string $recipe * @param string $recipe
        * The recipe to use for installing. * The recipe to use for installing.
        * @param string|null $password
        * The password to use for installing.
        * *
        * @throws \Exception * @throws \Exception
        * Thrown when failing to create the $site_path directory or settings.php. * Thrown when failing to create the $site_path directory or settings.php.
        ...@@ -161,9 +164,9 @@ protected function isDrupalInstalled() { ...@@ -161,9 +164,9 @@ protected function isDrupalInstalled() {
        * @return int * @return int
        * The command exit status. * The command exit status.
        */ */
        protected function install($class_loader, SymfonyStyle $io, $profile, $langcode, $site_path, $site_name, string $recipe) { protected function install($class_loader, SymfonyStyle $io, $profile, $langcode, $site_path, $site_name, string $recipe, ?string $password = NULL) {
        $sqliteDriverNamespace = 'Drupal\\sqlite\\Driver\\Database\\sqlite'; $sqliteDriverNamespace = 'Drupal\\sqlite\\Driver\\Database\\sqlite';
        $password = Crypt::randomBytesBase64(12); $password ??= Crypt::randomBytesBase64(12);
        $parameters = [ $parameters = [
        'interactive' => FALSE, 'interactive' => FALSE,
        'site_path' => $site_path, 'site_path' => $site_path,
        ......
        ...@@ -30,6 +30,7 @@ protected function configure() { ...@@ -30,6 +30,7 @@ protected function configure() {
        ->setDescription('Installs a Drupal site and runs a web server. This is not meant for production and might be too simple for custom development. It is a quick and easy way to get Drupal running.') ->setDescription('Installs a Drupal site and runs a web server. This is not meant for production and might be too simple for custom development. It is a quick and easy way to get Drupal running.')
        ->addArgument('install-profile-or-recipe', InputArgument::OPTIONAL, 'Install profile or recipe directory from which to install the site.') ->addArgument('install-profile-or-recipe', InputArgument::OPTIONAL, 'Install profile or recipe directory from which to install the site.')
        ->addOption('langcode', NULL, InputOption::VALUE_OPTIONAL, 'The language to install the site in. Defaults to en.', 'en') ->addOption('langcode', NULL, InputOption::VALUE_OPTIONAL, 'The language to install the site in. Defaults to en.', 'en')
        ->addOption('password', NULL, InputOption::VALUE_OPTIONAL, 'Set the administrator password. Defaults to a randomly generated password.')
        ->addOption('site-name', NULL, InputOption::VALUE_OPTIONAL, 'Set the site name. Defaults to Drupal.', 'Drupal') ->addOption('site-name', NULL, InputOption::VALUE_OPTIONAL, 'Set the site name. Defaults to Drupal.', 'Drupal')
        ->addOption('host', NULL, InputOption::VALUE_OPTIONAL, 'Provide a host for the server to run on. Defaults to 127.0.0.1.', '127.0.0.1') ->addOption('host', NULL, InputOption::VALUE_OPTIONAL, 'Provide a host for the server to run on. Defaults to 127.0.0.1.', '127.0.0.1')
        ->addOption('port', NULL, InputOption::VALUE_OPTIONAL, 'Provide a port for the server to run on. Will be determined automatically if none supplied.') ->addOption('port', NULL, InputOption::VALUE_OPTIONAL, 'Provide a port for the server to run on. Will be determined automatically if none supplied.')
        ...@@ -52,6 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ...@@ -52,6 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
        'command' => 'install', 'command' => 'install',
        'install-profile-or-recipe' => $input->getArgument('install-profile-or-recipe'), 'install-profile-or-recipe' => $input->getArgument('install-profile-or-recipe'),
        '--langcode' => $input->getOption('langcode'), '--langcode' => $input->getOption('langcode'),
        '--password' => $input->getOption('password'),
        '--site-name' => $input->getOption('site-name'), '--site-name' => $input->getOption('site-name'),
        ]; ];
        ......
        ...@@ -155,6 +155,7 @@ public function testQuickStartInstallAndServerCommands(): void { ...@@ -155,6 +155,7 @@ public function testQuickStartInstallAndServerCommands(): void {
        'core/scripts/drupal', 'core/scripts/drupal',
        'install', 'install',
        'testing', 'testing',
        "--password='secret'",
        "--site-name='Test site {$this->testDb->getDatabasePrefix()}'", "--site-name='Test site {$this->testDb->getDatabasePrefix()}'",
        ]; ];
        $install_process = new Process($install_command, NULL, ['DRUPAL_DEV_SITE_PATH' => $this->testDb->getTestSitePath()]); $install_process = new Process($install_command, NULL, ['DRUPAL_DEV_SITE_PATH' => $this->testDb->getTestSitePath()]);
        ...@@ -162,6 +163,7 @@ public function testQuickStartInstallAndServerCommands(): void { ...@@ -162,6 +163,7 @@ public function testQuickStartInstallAndServerCommands(): void {
        $result = $install_process->run(); $result = $install_process->run();
        // The progress bar uses STDERR to write messages. // The progress bar uses STDERR to write messages.
        $this->assertStringContainsString('Congratulations, you installed Drupal!', $install_process->getErrorOutput()); $this->assertStringContainsString('Congratulations, you installed Drupal!', $install_process->getErrorOutput());
        $this->assertStringContainsString("Password: 'secret'", $install_process->getOutput());
        $this->assertSame(0, $result); $this->assertSame(0, $result);
        // Run the PHP built-in webserver. // Run the PHP built-in webserver.
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment