diff --git a/core/lib/Drupal/Core/Command/ServerCommand.php b/core/lib/Drupal/Core/Command/ServerCommand.php index d7d7402924..850098ad82 100644 --- a/core/lib/Drupal/Core/Command/ServerCommand.php +++ b/core/lib/Drupal/Core/Command/ServerCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Process\PhpExecutableFinder; +use Symfony\Component\Process\PhpProcess; use Symfony\Component\Process\Process; /** @@ -139,11 +140,7 @@ protected function openBrowser($url, SymfonyStyle $io, $wait = 0) { $is_windows = defined('PHP_WINDOWS_VERSION_BUILD'); if ($is_windows) { // Handle escaping ourselves. - $cmd = 'start "web" explorer ' . $url; - $cmd_concat = '; '; - } - else { - $cmd_concat = ' && '; + $cmd = 'start ' . $url; } $is_linux = (new Process('which xdg-open'))->run(); @@ -161,15 +158,17 @@ protected function openBrowser($url, SymfonyStyle $io, $wait = 0) { return; } - if ($wait) { - $cmd = 'sleep ' . $wait . $cmd_concat . $cmd; - } - if ($io->isVerbose()) { $io->writeln("Browser command: $cmd"); } - (new Process($cmd))->start(); + // Need to escape double quotes in the command so the PHP will work. + $cmd = str_replace('"', '\"', $cmd); + // Sleep in PHP so that Windows powershell users also get a browser opened + // for them. + $php = ""; + $process = new PhpProcess($php); + $process->start(); return; } @@ -215,8 +214,7 @@ protected function start($host, $port, DrupalKernelInterface $kernel, InputInter $io->writeln('Press Ctrl-C to quit.'); if (!$input->getOption('suppress-login')) { - // @todo Fix redirect to the front page. - if ($this->openBrowser("$one_time_login?destination=" . urlencode("/"), $io, 2) === 1) { + if ($this->openBrowser($one_time_login, $io, 2) === 1) { $io->error('Error while opening up a one time login URL'); } }