diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index bebe9ab..4c78082 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -253,32 +253,6 @@ function timer_stop($name) { } /** - * Rebuilds all caches even when Drupal itself does not work. - * - * Requires DRUPAL_BOOTSTRAP_CONFIGURATION. - * - * @see rebuild.php - */ -function drupal_rebuild() { - // 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(); -} - -/** * Returns the appropriate configuration directory. * * Returns the configuration path based on the site's hostname, port, and diff --git a/core/includes/utility.inc b/core/includes/utility.inc index 5b2719d..a900262 100644 --- a/core/includes/utility.inc +++ b/core/includes/utility.inc @@ -6,6 +6,8 @@ */ use Drupal\Component\Utility\Variable; +use Drupal\Component\PhpStorage\PhpStorageFactory; +use Drupal\Core\Cache\Cache; /** * Drupal-friendly var_export(). @@ -23,3 +25,29 @@ function drupal_var_export($var, $prefix = '') { return Variable::export($var, $prefix); } + +/** + * Rebuilds all caches even when Drupal itself does not work. + * + * Requires DRUPAL_BOOTSTRAP_CONFIGURATION. + * + * @see rebuild.php + */ +function drupal_rebuild() { + // 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(); +} diff --git a/core/rebuild.php b/core/rebuild.php index 101a1a9..1b94601 100644 --- a/core/rebuild.php +++ b/core/rebuild.php @@ -16,6 +16,8 @@ chdir('..'); require_once dirname(__DIR__) . '/core/includes/bootstrap.inc'; +require_once dirname(__DIR__) . '/core/includes/utility.inc'; + drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); if (settings()->get('rebuild_access', FALSE) || @@ -23,6 +25,7 @@ ((REQUEST_TIME - $_GET['timestamp']) < 300) && ($_GET['token'] === Crypt::hmacBase64($_GET['timestamp'], $GLOBALS['drupal_hash_salt'])) )) { + drupal_rebuild(); drupal_set_message('Cache rebuild complete.'); }