This is required to #299308: Installing Drupal by visiting index.php (rather than install.php) leads to a fatal error when PDO is not enabled.

The patch detects during the DRUPAL_BOOTSTRAP_CONFIGURATION phase if there is not a connection defined. In this case, the user is redirected to the installer, permitting to check if PDO is available before including the DB abstraction layer.

CommentFileSizeAuthor
redir-to-install-early.patch3.3 KBdropcube

Comments

Anonymous’s picture

Status: Needs review » Needs work

The code looks nice; just need some testing. Oops, just found an issue with the _drupal_install_required function in your patch. The install_goto will not be called if it already is defined. The if condition isn't needed since PHP takes care of that naturally.

OT: I think a usability issue is one where the DB isn't available but has been installed already. Should the _drupal_install_required function check for !empty($databases) and put up a no_db.php instead?

 /**
  * Send the user to the installer page.
  */
  function _drupal_install_required() {
    global $databases;

    include_once DRUPAL_ROOT . '/includes/install.inc';

    if (empty($databases)) {
     install_goto('install.php');
    }
    else {
     install_goto('no_db.php');  
    }
  }
dropcube’s picture

Status: Needs work » Needs review

@earnie: I created this function from _db_need_install. Actually, the condition is needed: if install_goto is defined, then we are in an install/update process, so no redirection required.

I think a usability issue is one where the DB isn't available but has been installed already. Should the _drupal_install_required function check for !empty($databases) and put up a no_db.php instead?

Currently, this is correctly handled by the installer system. What I mean is that the global $databases variable is not defined, because a the settings file is not created or whatever, no that the DB is not available, this is other issue.

Anonymous’s picture

But since install.inc isn't normally included then install_goto will not be defined to give a clue to update versus install. Therefore the if condition will always be met except for during the install phase. Ok, I can see that the install phase will call this function as well and the condition is avoiding endless recursion. I still need to test this.

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

Paul Natsuo Kishimoto’s picture

This was linked from #14 over at the source issue; at #43 a tester reports "The patch in #42 works fine with and without PDO enabled and with and without $databases setting in settings.php." Is this issue no longer needed?

jbrown’s picture

moshe weitzman’s picture

Priority: Critical » Normal

no response. downgrading.

David_Rothstein’s picture

I think this patch might be needed to solve the followup issue that came up at #299308: Installing Drupal by visiting index.php (rather than install.php) leads to a fatal error when PDO is not enabled - in particular the discussion starting at http://drupal.org/node/299308#comment-2501468

The overall approach seems to make sense here. I believe we already call this function on every page request anyway, so it makes sense to consolidate it and try to call it once up front, as early as possible. I wonder a bit if this would affect scripts like update.php or authorize.php in any weird way though - maybe they're OK.

Crell’s picture

Subscribing.

David_Rothstein’s picture

Status: Needs work » Fixed

#299308-141: Installing Drupal by visiting index.php (rather than install.php) leads to a fatal error when PDO is not enabled was committed, which moves the check to the beginning of DRUPAL_BOOSTRAP_DATABASE and solves the PDO problem.

Therefore, marking this fixed (the patch here would have moved it all the way to DRUPAL_BOOTSTRAP_CONFIGURATION but I don't know of any reason why we need it that early - reopen if there is).

Status: Fixed » Closed (fixed)

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