Commit 750b5273 authored by alexpott's avatar alexpott
Browse files

Issue #1872522 by chx, effulgentsia, sun, aspilicious, desmondmorris, Berdir,...

Issue #1872522 by chx, effulgentsia, sun, aspilicious, desmondmorris, Berdir, jibran, YesCT: Fixed Compiled data in PHP storage is cleared too late in drupal_flush_all_caches().
parent 66e6eb8d
......@@ -3,8 +3,6 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Cache\Cache;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Yaml\Parser;
use Drupal\Component\PhpStorage\PhpStorageFactory;
use Drupal\Component\Utility\NestedArray;
......@@ -6069,10 +6067,11 @@ function drupal_implode_tags($tags) {
* requests.
function drupal_flush_all_caches() {
$module_handler = Drupal::moduleHandler();
// Flush all persistent caches.
// This is executed based on old/previously known information, which is
// sufficient, since new extensions cannot have any primed caches yet.
foreach (Cache::getBins() as $service_id => $cache_backend) {
if ($service_id != '') {
......@@ -6088,16 +6087,32 @@ function drupal_flush_all_caches() {
// Clear all non-drupal_static() static caches.
// @todo Rebuild the kernel/container.
// Wipe the PHP Storage caches.
// Rebuild module and theme data.
$module_data = system_rebuild_module_data();
// Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not
// sufficient, since the list of enabled modules might have been adjusted
// above due to changed code.
$files = array();
foreach ($module_data as $module => $data) {
if (isset($data->uri) && $data->status) {
$files[$module] = $data->uri;
Drupal::service('kernel')->updateModules($module_handler->getModuleList(), $files);
// New container, new module handler.
$module_handler = Drupal::moduleHandler();
// Ensure that all modules that are currently supposed to be enabled are
// actually loaded.
// Update the list of bootstrap modules.
// Allows developers to get new bootstrap hooks implementations registered
......@@ -6113,18 +6128,14 @@ function drupal_flush_all_caches() {
drupal_get_schema(NULL, TRUE);
// Rebuild all information based on new module data.
// Rebuild the menu router based on all rebuilt data.
// Important: This rebuild must happen last, so the menu router is guaranteed
// to be based on up to date information.
// Wipe the PHP Storage caches.
// Re-initialize the maintenance theme, if the current request attempted to
// use it. Unlike regular usages of this function, the installer and update
// scripts need to flush all caches during GET requests/page building.
......@@ -431,7 +431,19 @@ protected function buildContainer() {
foreach ($this->bundles as $bundle) {
$container->setParameter('persistIds', array_keys($container->findTaggedServiceIds('persist')));
// Identify all services whose instances should be persisted when rebuilding
// the container during the lifetime of the kernel (e.g., during a kernel
// reboot). Include synthetic services, because by definition, they cannot
// be automatically reinstantiated. Also include services tagged to persist.
$persist_ids = array();
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isSynthetic() || $definition->getTag('persist')) {
$persist_ids[] = $id;
$container->setParameter('persistIds', $persist_ids);
return $container;
......@@ -909,6 +909,7 @@ protected function writeSettings($settings) {
protected function resetAll() {
// Clear all database and static caches and rebuild data structures.
$this->container = \Drupal::getContainer();
// Reload global $conf array and permissions.
......@@ -9,4 +9,10 @@
require_once __DIR__ . '/core/includes/';
try {
catch (Exception $e) {
print 'If you have just changed code (for example deployed a new module or moved an existing one) read';
throw $e;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment