If you have already configured database connection information in settings.php, the installer will refuse to continue (even if Drupal isn't actually installed). There's an existing function that - I think? - is meant to check for this, but it's not called anywhere as far as I can see (install_verify_database_ready() ).

Comments

cweagans created an issue. See original summary.

cweagans’s picture

Patch attached does the following:

1) Centralize detection of whether or not Drupal is installed into drupal_is_installed()
2) Deprecates install_verify_database_ready(), since it's largely duplicating what's in drupal_is_installed()
3) Call drupal_is_installed() from install_verify_database_ready()
4) Use drupal_is_installed() in the installer to detect whether or not Drupal is installed

cweagans’s picture

Status: Active » Needs review
StatusFileSize
new3.77 KB
new1.48 KB

Added one more place where drupal_is_installed() should be used.

cweagans’s picture

Status: Needs review » Needs work

I'm going to do a bit more on this tomorrow..er..later today. Stand by.

cweagans’s picture

Status: Needs work » Needs review
StatusFileSize
new11.92 KB

chx asked me to convert this to a service, rather than hardcoding a new query into every page load. Basically an entirely new patch at this point.

Status: Needs review » Needs work

The last submitted patch, 5: 2581457_05.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

The last submitted patch, 5: 2581457_05.patch, failed testing.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kingdutch’s picture

Assigned: cweagans » Unassigned

Unassigning as this has been dormant for about a year. The issue is still alive and kicking.

The latest patch (using a service) container still needs some work.

The first problem I encountered (running a set-up with settings.php preconfigured) was that it could not find the `install_check` service. This is because the installer doesn't load the entire container from the services.yml file but uses a stripped down version in `install_begin_request` of `install.core.inc`. Adding the following snipped within the guard of `if ($install_state['settings_verified']) {` before the call to `drupal_is_installed()` fixed that first issue.

    $install_check_definition = new Definition();
    $install_check_definition
      ->setFactory('Drupal\Core\Site\InstallCheck\DatabaseInstallCheck::create')
      ->addArgument(new Reference('service_container'));
    $definitions = array('install_check' => $install_check_definition);
    $container->addDefinitions($definitions);

This snippet uses the a custom definition because I couldn't find a shorthand to add a factory to the container. I'm unsure why this classes uses a factory in the first place. It feels like we only ever need one instance of this service but I'm trying to keep changes minimal as my experience with Drupal 8 is limited.

The following problem we have is that the database service isn't registered. I'm not entirely sure how to fix that. The if statement in `install_begin_request` ensures the database is ready so it would be possible to register the needed service to the container. But this feels like the install method is growing quickly for a relatively simple check so I'm not entirely sure if that's the correct path forward.

lennard westerveld’s picture

Hi @Kingdutch,

Seems it has been fixed for me in 8.3.x did you also test it with the new release candidate?

Kind regards,
Lennard

kingdutch’s picture

Status: Needs work » Reviewed & tested by the community

Hey @Lennard,

Yes it seems to have been fixed in 3.0-rc2 : )

Removed another patch to make it work. A non installed site now redirects from index to install. Select a language and the installer starts. That's great!

Looks like the the first patch was partially implemented (the drupal_is_installed function can't be found but the check in the installer is present).

Marking this RTBC because I'm not sure if this still needs some kind of Change Record or can just be marked as fixed. I'll leave that to a maintainer :)

Now off to tackle the next error I encounter (unrelated to this issue).

alexpott’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

This was fixed by #728702: Visiting index.php should redirect to install.php if settings.php already has database credentials but database is empty. which landed in 8.3.x - and has a CR https://www.drupal.org/node/2797353

If I'm wrong - please comment and I'll re-open the issue. I'm not sure a specific CR is necessary - this just works now - at long last.