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/modules/system/system.install b/core/modules/system/system.install index 4f848ce..f15cdc6 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -518,6 +518,15 @@ function system_requirements($phase) { ); } $requirements['update status']['title'] = t('Update notifications'); + + if (settings()->get('rebuild_access')) { + $requirements['rebuild access'] = array( + 'title' => t('Rebuild access'), + 'value' => t('Enabled'), + 'severity' => REQUIREMENT_ERROR, + 'description' => t('The rebuild_access setting is enabled in settings.php. It is recommended to have this setting disabled unless you are performing a rebuild.'), + ); + } } // Ensure that if upgrading from 7 to 8 we have no disabled modules. diff --git a/core/rebuild.php b/core/rebuild.php new file mode 100644 index 0000000..597361e --- /dev/null +++ b/core/rebuild.php @@ -0,0 +1,45 @@ +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(); + + // Disable the page cache. + drupal_page_is_cacheable(FALSE); + + // Bootstrap up to where caches exist and clear them. + drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE); + foreach (Cache::getBins() as $bin) { + $bin->deleteAll(); + } + + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); + drupal_flush_all_caches(); + 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 new file mode 100755 index 0000000..9b948b4 --- /dev/null +++ b/core/scripts/rebuild_token_calculator.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env php + +