summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-10-30 19:27:27 (GMT)
committerNathaniel Catchpole2016-10-30 19:27:27 (GMT)
commit561580c43fada75ccb528afc86c04679a6b540b7 (patch)
tree70f6c0798695c49c378139afbc325411e7f97889
parent9bdda95a2b63cc864f0a3301869a6656cd0ec068 (diff)
Issue #2556025 by david_garcia, dawehner, -enzo-, Fabianx, catch: Make optimized class loader detection more generic to support class loaders other than ApcClassLoader
-rw-r--r--core/includes/utility.inc9
-rw-r--r--core/lib/Drupal/Core/DrupalKernel.php31
-rw-r--r--core/rebuild.php12
3 files changed, 36 insertions, 16 deletions
diff --git a/core/includes/utility.inc b/core/includes/utility.inc
index 2bb6507..70d74a1 100644
--- a/core/includes/utility.inc
+++ b/core/includes/utility.inc
@@ -9,19 +9,20 @@ use Drupal\Core\PhpStorage\PhpStorageFactory;
use Drupal\Core\Cache\Cache;
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
-use Composer\Autoload\ClassLoader;
/**
* 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 ba2c0fb..274a3fa 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -23,6 +23,8 @@ use Drupal\Core\Site\Settings;
use Drupal\Core\Test\TestDatabase;
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;
@@ -1028,16 +1030,29 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
}
}
- // 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..fc432d7 100644
--- a/core/rebuild.php
+++ b/core/rebuild.php
@@ -42,10 +42,14 @@ if (Settings::get('rebuild_access', FALSE) ||
((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 = [
+ '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.');
}