Skip to content

Instantly share code, notes, and snippets.

@pounard
Last active April 26, 2016 09:35
Show Gist options
  • Save pounard/2309c22c10ee0391ea2990a4b5b316ee to your computer and use it in GitHub Desktop.
Save pounard/2309c22c10ee0391ea2990a4b5b316ee to your computer and use it in GitHub Desktop.
This script will save your life
#!/usr/bin/php
<?php
if (!isset($argv[1])) {
$host = '127.0.0.1';
} else {
$host = $argv[1];
}
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_HOST'] = $host;
$_SERVER['SCRIPT_NAME'] = '/index.php';
define('DRUPAL_ROOT', __DIR__ . '/../www');
chdir(DRUPAL_ROOT);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/database/database.inc';
require_once DRUPAL_ROOT . '/includes/cache.inc';
require_once DRUPAL_ROOT . '/includes/file.inc';
require_once DRUPAL_ROOT . '/includes/module.inc';
require_once DRUPAL_ROOT . '/includes/registry.inc';
echo "working in ", conf_path(), "\n";
drupal_environment_initialize();
drupal_settings_initialize();
restore_error_handler();
restore_exception_handler();
_drupal_bootstrap_database();
echo "cache system enable attempt\n";
if (!empty($conf['cache_backends'])) {
foreach ($conf['cache_backends'] as $include) {
echo "requiring ", $include, "\n";
require_once DRUPAL_ROOT . '/' . $include;
}
}
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
echo "system_rebuild_module_data()\n";
require_once DRUPAL_ROOT . '/includes/common.inc';
require_once DRUPAL_ROOT . '/modules/system/system.module';
drupal_static_reset('system_rebuild_module_data');
system_rebuild_module_data();
echo "_registry_update()\n";
_registry_update();
echo "all done\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment