diff --git a/.htaccess b/.htaccess index ce89e17..526c60b 100644 --- a/.htaccess +++ b/.htaccess @@ -111,7 +111,8 @@ DirectoryIndex index.php index.html index.htm # Redirect common PHP files to their new locations. RewriteCond %{REQUEST_URI} ^(.*)?/(update.php) [OR] - RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) + RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR] + RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild.php) RewriteCond %{REQUEST_URI} !core RewriteRule ^ %1/core/%2 [L,QSA,R=301] diff --git a/core/rebuild.php b/core/rebuild.php index 9ecf17d..4a83715 100644 --- a/core/rebuild.php +++ b/core/rebuild.php @@ -9,7 +9,7 @@ */ use Drupal\Component\PhpStorage\PhpStorageFactory; -use Drupal\Core\Cache\CacheFactory; +use Drupal\Core\Cache\Cache; use Drupal\Component\Utility\Crypt; // Change the directory to the Drupal root. @@ -17,18 +17,27 @@ require_once dirname(__DIR__) . '/core/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); -if (isset($_GET['token']) && isset($_GET['timestamp']) && REQUEST_TIME - $_GET['timestamp'] < 300 && $_GET['token'] === ($_GET['timestamp'], $GLOBALS['drupal_hash_salt'])) { - // drupal_bootstrap(DRUPAL_BOOTSTRAP_KERNEL) will build a new kernel. + +if (settings()->get('rebuild_access', FALSE) || + (isset($_GET['token'], $_GET['timestamp']) && + ((REQUEST_TIME - $_GET['timestamp']) < 300) && + ($_GET['token'] === Crypt::hmacBase64($_GET['timestamp'], $GLOBALS['drupal_hash_salt'])) + )) { + // drupal_bootstrap(DRUPAL_BOOTSTRAP_KERNEL) will build a new kernel. This + // comes before DRUPAL_BOOTSTRAP_PAGE_CACHE. PhpStorageFactory::get('service_container')->deleteAll(); PhpStorageFactory::get('twig')->deleteAll(); $GLOBALS['conf']['system.performance']['cache.page.use_internal'] = FALSE; + // Bootstrap up to where caches exist and clear them. drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE); - foreach (CacheFactory::getBackends() as $bin => $backend) { - cache($bin)->deleteAll(); + foreach (Cache::getBins() as $bin) { + $bin->deleteAll(); } + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_flush_all_caches(); - drupal_set_message('Rebuild complete.'); + drupal_set_message('Cache rebuild complete.'); } + header('Location: ' . $GLOBALS['base_url']); diff --git a/core/scripts/rebuild_token_calculator.sh b/core/scripts/rebuild_token_calculator.sh index 2369cd8..e9d8832 100755 --- a/core/scripts/rebuild_token_calculator.sh +++ b/core/scripts/rebuild_token_calculator.sh @@ -1,4 +1,5 @@ #!/usr/bin/env php +