Problem

  1. install_begin_request() is a utter mess.
  2. We are not able to modernize the installer with this code.

Goal

  1. Replace the minimal container(s) in install_begin_request() with a proper kernel.

Proposed solution

  1. All of the minimal ContainerBuilder instances in install_begin_request() are replaced with a single, regular DrupalKernel.
  2. If the base system is not ready to operate yet, then a new InstallServiceProvider is added to the kernel, which replaces all persistent storage services with memory/null implementations.

Comments

sun’s picture

Here we go.

Status: Needs review » Needs work

The last submitted patch, 1: install.kernel.1.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new32.16 KB
new2.4 KB

Fixed last minute cleanup/optimization: theme_handler needs a Routing\MatcherDumper.

Status: Needs review » Needs work

The last submitted patch, 3: install.kernel.3.patch, failed testing.

dawehner’s picture

Issue summary: View changes

Fixed last minute cleanup/optimization: theme_handler needs a Routing\MatcherDumper.

Just a hint, it uses a route builder not a matcher dumper.

sun’s picture

Issue summary: View changes
sun’s picture

Status: Needs work » Needs review
StatusFileSize
new39.63 KB
new12.12 KB
  1. Fixed request service of install kernel is not scoped.
  2. Fixed error/exception handlers cannot be reverted, because that also reverts test handlers.
  3. Fixed drupal_override_server_variables() is completely broken.
  4. Fixed some installer forms do not prevent form redirection.
sun’s picture

sun’s picture

  1. Moved service provider into proper Drupal\Core\Installer component home.
  2. Use correct kernel environment name for the regular production kernel.
  3. Removed no longer relevant/used improvement to ModuleHandler:.setModuleList().
  4. Added a special InstallerRouteBuilder to avoid needless router building in early installer.

Status: Needs review » Needs work

The last submitted patch, 9: install.kernel.9.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new36.53 KB
new7.46 KB
  1. Fixed ConfigFactory::setOverrideState() can only be called after all services are overridden.
  2. Reverted removal of t(); supply a minimally mocked container to satisfy t() instead.
sun’s picture

Issue summary: View changes

Removed obsolete notes about t() from issue summary.

The last patch should come back green again.

dawehner’s picture

... took it back ...

dawehner’s picture

  1. +++ b/core/includes/install.inc
    @@ -625,19 +625,16 @@ function drupal_install_system($install_state) {
    +  $kernel = new DrupalKernel('prod', drupal_classloader(), FALSE);
    

    Just wondering whether 'prod' is really the right name. Can't we keep 'install' for semantic reasons?

  2. +++ b/core/lib/Drupal/Core/CoreServiceProvider.php
    @@ -86,27 +85,6 @@ public function register(ContainerBuilder $container) {
    -      // During installation we use the non-cached version.
    -      $container->register('module_handler', 'Drupal\Core\Extension\ModuleHandler')
    -        ->addArgument('%container.modules%');
    -    }
    

    So we not longer need to use the non-cached version? What was the reason before to need this?

sun’s picture

Thanks for reviewing! :)

Two simple and hopefully satisfying replies:

  1. 'prod' is the same environment name as the regular production kernel uses. There is factually no difference between the production kernel booted by the installer and the regular one, so I intentionally want to use the same environment name.
  2. The module_handler service override is obsolete for a very long time already, because the installer replaces the cache.bootstrap service with a memory backend. This also means that we can and should merge CachedModuleHandler into ModuleHandler, but I'm leaving that for a separate issue.

FWIW: I was successfully able to combine + leverage this code in #1808220: Remove run-tests.sh dependency on existing/installed parent site

run-tests.sh is able to operate without first having to install Drupal and enable Simpletest! :-)

moshe weitzman’s picture

run-tests.sh is able to operate without first having to install Drupal and enable Simpletest! :-)

.

That is awesome!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

That patch is good for now

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. use Drupal\Core\CoreServiceProvider;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    

    Are no longer used in install.core.inc

  2. use Drupal\Core\Language\Language;
    

    Not used in InstallerServiceProvider.php

  3. +++ b/core/lib/Drupal/Core/Routing/NullMatcherDumper.php
    @@ -0,0 +1,63 @@
    + * Dumps Route information into /dev/null.
    

    This is not true. It makes the dump operation not dump but it does not dump to /dev/null

  4. +++ b/core/includes/install.core.inc
    @@ -1565,9 +1411,9 @@ function install_select_language(&$install_state) {
    -  if ($request_params->has('langcode')) {
    ...
    -    $langcode = $request_params->get('langcode');
    

    Can remove $request_params = \Drupal::request()->request; from install_select_language() now.

  5. +++ b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php
    @@ -0,0 +1,82 @@
    +use Drupal\Core\DependencyInjection\ContainerInterface;
    

    Does not exist and is not used.

  6. +++ b/core/lib/Drupal/Core/Routing/NullMatcherDumper.php
    @@ -0,0 +1,63 @@
    +   * @var Symfony\Component\Routing\RouteCollection
    

    Missing leading slash.

sun’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new37.52 KB
new2.53 KB
  1. Removed unused use statements.
  2. Removed unused use statement from InstallerServiceProvider.
  3. Fixed phpDoc summary on NullMatcherDumper.
  4. Removed obsolete $request_params variable from install_select_language().
  5. Removed bogus/unused ContainerInterface use statement from InstallerServiceProvider.
  6. Fixed FQCN in phpDoc of NullMatcherDumper.

Since all of these were very minor, I hope it's OK if I move straight back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Nice. Less special installer code++

Committed 45e61d2 and pushed to 8.x. Thanks!

cosmicdreams’s picture

In reading this patch, I discovered an exciting @todo. In Drupal\Core\Installer\InstallerRouteBuilder there is a todo that states: "Convert installer steps into routes; add an installer.routing.yml"

Is there already a follow up issue for that?

sun’s picture

While that is indeed exciting, we first want/need to convert all of the trivial procedural code into classes (e.g. all of the forms).

I will create many actionable follow-up issues on which many people will be able to work on in parallel — once they exist, I will link to them in the parent issue #1530756: [meta] Use a proper kernel for the installer, so make sure to follow that. :-)

cosmicdreams’s picture

Great news! There's so many awesome things going on with the installer that it's a challenge to stay current / find ways to help. I'll keep at eye on that issue for further information.

Will this work enable being able to hook in custom install steps? Would be kind of nice to kick off a set of Migrate tasks during install for some kinds of projects.

sun’s picture

@cosmicdreams: Can you create an issue for that? (please search for possibly existing first) It sounds interesting, so I'd like to better understand and discuss what the situation/challenge is. :)

cosmicdreams’s picture

Sure thing. Only thing is, this is functionality we already have in D7. For example take a look at the AbleOrganizer distribution. As a part of it's final install steps it loads sample data into the site in order to demonstrate the system and its reporting capabilities.

My request is to not lose that capability while presenting a DX experience that make it easy to know how to extend the installation process with additional tasks.

And that sounds a lot like what we had with D7. It makes me wonder if I really do need to open a ticket for this. I'm just asking to keep that capability despite the changes to the underlying architecture.

sun’s picture

@cosmicdreams: Yes, that functionality exists and should still work. But to my knowledge, there are no tests for it, so the best you can do to ensure that it will still work is to create an issue to add test coverage for this apparently undocumented and untested feature ;-)

Status: Fixed » Closed (fixed)

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