3

I'm looking for a way to reliably detect whether Drupal's install process is currently running, either via drush site-install or install.php.

The immediate problem I'm trying to solve is that I have some settings (using Redis as cache backend) in settings.php which cause the installation to fail. So I'd like to wrap that block of settings in something like if (!drupal_installation_is_currently_running()) { … }

I have not managed to figure out how that can reliably be determined. Any suggestions?

4

You're probably looking for drupal_installation_attempted():

Returns TRUE if a Drupal installation is currently being attempted.

  • This doesn't work on settings.php – Gerardo May 5 '16 at 4:44
  • It wouldn't do - Drupal isn't bootstrapped when settings.php is included – Clive May 5 '16 at 6:49
0

I think I found a solution:

if (defined('MAINTENANCE_MODE') && constant('MAINTENANCE_MODE') === 'install')

If null, or another value, then not in install mode. Unfortunately, there is some code that executes before the install.php redirect is triggered. So you might still run into problems before the define('MAINTENANCE_MODE', 'install'); is called inside of install.php.

This solutions is working well for me in that it allows me to set $conf['preprocess_js'] = true when $_SERVER['PANTHEON_ENVIRONMENT'] equals 'test' or 'live'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.