diff --git a/core/includes/utility.inc b/core/includes/utility.inc index 2bb6507..f7da391 100644 --- a/core/includes/utility.inc +++ b/core/includes/utility.inc @@ -14,14 +14,16 @@ /** * Rebuilds all caches even when Drupal itself does not work. * - * @param \Composer\Autoload\ClassLoader $class_loader - * The class loader. + * @param $class_loader + * The class loader. Normally Composer's ClassLoader, as included by the + * front controller, but may also be decorated; e.g., + * \Symfony\Component\ClassLoader\ApcClassLoader, \Symfony\Component\ClassLoader\WinCacheClassLoader, or \Symfony\Component\ClassLoader\XcacheClassLoader * @param \Symfony\Component\HttpFoundation\Request $request * The current request. * * @see rebuild.php */ -function drupal_rebuild(ClassLoader $class_loader, Request $request) { +function drupal_rebuild($class_loader, Request $request) { // Remove Drupal's error and exception handlers; they rely on a working // service container and other subsystems and will only cause a fatal error // that hides the actual error. diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 3ccb2d7..f6ee5f1 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -20,6 +20,8 @@ use Drupal\Core\Site\Settings; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\ClassLoader\ApcClassLoader; +use Symfony\Component\ClassLoader\WinCacheClassLoader; +use Symfony\Component\ClassLoader\XcacheClassLoader; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -1001,16 +1003,29 @@ protected function initializeSettings(Request $request) { } } - // If the class loader is still the same, possibly upgrade to the APC class - // loader. + // If the class loader is still the same, possibly + // upgrade to an optimized class loader. if ($class_loader_class == get_class($this->classLoader) - && Settings::get('class_loader_auto_detect', TRUE) - && function_exists('apcu_fetch')) { + && Settings::get('class_loader_auto_detect', TRUE)) { $prefix = Settings::getApcuPrefix('class_loader', $this->root); - $apc_loader = new ApcClassLoader($prefix, $this->classLoader); - $this->classLoader->unregister(); - $apc_loader->register(); - $this->classLoader = $apc_loader; + $loader = NULL; + + // We autodetect one of the following three optimized classloaders, if + // their underlying extension exists. + if (function_exists('apcu_fetch')) { + $loader = new ApcClassLoader($prefix, $this->classLoader); + } + elseif (extension_loaded('wincache')) { + $loader = new WinCacheClassLoader($prefix, $this->classLoader); + } + elseif (extension_loaded('xcache')) { + $loader = new XcacheClassLoader($prefix, $this->classLoader); + } + if (!empty($loader)) { + $this->classLoader->unregister(); + $loader->register(); + $this->classLoader = $loader; + } } } diff --git a/core/rebuild.php b/core/rebuild.php index 4e69eab..eee03e7 100644 --- a/core/rebuild.php +++ b/core/rebuild.php @@ -42,10 +42,16 @@ ((REQUEST_TIME - $request->query->get('timestamp')) < 300) && Crypt::hashEquals(Crypt::hmacBase64($request->query->get('timestamp'), Settings::get('hash_salt')), $request->query->get('token')) )) { - // Clear the APCu cache to ensure APCu class loader is reset. - if (function_exists('apcu_clear_cache')) { - apcu_clear_cache(); - } + // Clear user cache for all major platforms. + $user_caches = [ + 'apc_clear_cache', + 'apcu_clear_cache', + 'wincache_ucache_clear', + 'xcache_clear_cache', + ]; + array_walk(array_filter($user_caches, 'is_callable'), 'call_user_func'); +}); + drupal_rebuild($autoloader, $request); drupal_set_message('Cache rebuild complete.'); }