diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 475d8d1..9ff9c0f 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -343,7 +343,7 @@ function install_begin_request(&$install_state) { drupal_load('module', 'system'); require_once DRUPAL_ROOT . '/core/includes/cache.inc'; - $conf['cache_classes'] = array('cache' => 'Drupal\Core\Cache\NullBackend'); + $conf['cache_classes'] = array('cache' => 'Drupal\Core\Cache\MemoryBackend'); // The install process cannot use the database lock backend since the database // is not fully up, so we use a null backend implementation during the diff --git a/core/includes/update.inc b/core/includes/update.inc index 56b862f..16974a5 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -140,9 +140,6 @@ function update_prepare_d8_bootstrap() { // compatible yet. Use the null backend by default to avoid exceptions. $GLOBALS['conf']['cache_classes'] = array('cache' => 'Drupal\Core\Cache\NullBackend'); drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); - // Now remove the cache override. - unset($GLOBALS['conf']['cache_classes']['cache']); - drupal_static_reset('cache'); // If the site has not updated to Drupal 8 yet, check to make sure that it is // running an up-to-date version of Drupal 7 before proceeding. Note this has @@ -414,6 +411,9 @@ function update_prepare_d8_bootstrap() { db_change_field('url_alias', 'language', 'langcode', $langcode_spec, $langcode_indexes); } } + // Now remove the cache override. + unset($GLOBALS['conf']['cache_classes']['cache']); + drupal_static_reset('cache'); } } diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php index b2db00f..a22fc3c 100644 --- a/core/lib/Drupal/Core/Database/Query/Merge.php +++ b/core/lib/Drupal/Core/Database/Query/Merge.php @@ -124,11 +124,15 @@ class Merge extends Query implements ConditionInterface { protected $needsUpdate = FALSE; /** - * TRUE when execute() runs for the second time. + * TRUE when Merge::execute() runs for the second time. * - * @var boolean + * There could have been a deadlock problem with another transaction. This + * flag is used to retry exactly once and if that still fails, assume a + * permament failure and abort. + * + * @var bool */ - protected $retry = FALSE; + protected $secondTry = FALSE; /** * Constructs a Merge object. @@ -423,16 +427,17 @@ public function execute() { $insert->useDefaults($this->defaultFields); } $insert->execute(); - $this->retry = FALSE; + $this->secondTry = FALSE; return self::STATUS_INSERT; } catch (IntegrityConstraintViolationException $e) { - // Retry only once. - if ($this->retry) { - throw $e; + // Could be a temporary problem (lock), retry once. + if (!$this->secondTry) { + $this->secondTry = TRUE; + return $this->execute(); } - $this->retry = TRUE; - return $this->execute(); + // In case we already tried a second time, throw the exception. + throw $e; } } if ($this->needsUpdate) { diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php index 37d893d..cde0aeb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php @@ -26,11 +26,8 @@ public static function getInfo() { ); } - /** - * Tests DIC compilation. - */ - function testCompileDIC() { - $classloader = drupal_classloader(); + function setUp() { + parent::setUp(); global $conf; $conf['php_storage']['service_container']= array( 'bin' => 'service_container', @@ -38,7 +35,15 @@ function testCompileDIC() { 'directory' => DRUPAL_ROOT . '/' . variable_get('file_public_path', conf_path() . '/files') . '/php', 'secret' => $GLOBALS['drupal_hash_salt'], ); - $conf['cache_classes'] = array('cache' => 'Drupal\Core\Cache\NullBackend'); + // Use a non-persistent cache to avoid queries to non-existing tables. + $conf['cache_classes'] = array('cache' => 'Drupal\Core\Cache\MemoryBackend'); + } + + /** + * Tests DIC compilation. + */ + function testCompileDIC() { + $classloader = drupal_classloader(); // @todo: write a memory based storage backend for testing. $module_enabled = array( 'system' => 'system', @@ -61,6 +66,7 @@ function testCompileDIC() { // Now use the read-only storage implementation, simulating a "production" // environment. + global $conf; $conf['php_storage']['service_container']['class'] = 'Drupal\Component\PhpStorage\FileReadOnlyStorage'; $kernel = new DrupalKernel('testing', FALSE, $classloader); $kernel->updateModules($module_enabled); @@ -106,6 +112,5 @@ function testCompileDIC() { // Check that the location of the new module is registered. $modules = $container->getParameter('container.modules'); $this->assertEqual($modules['bundle_test'], drupal_get_filename('module', 'bundle_test')); - unset($conf['cache_classes']); } } diff --git a/core/modules/views/lib/Drupal/views/ViewsDataCache.php b/core/modules/views/lib/Drupal/views/ViewsDataCache.php index b117d52..89c7ff0 100644 --- a/core/modules/views/lib/Drupal/views/ViewsDataCache.php +++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.php @@ -215,9 +215,11 @@ public function __destruct() { $this->set($cid, $data); } } - } catch (\Exception $e) { - // During testing the table is gone before this fires. Nasty. - // @todo remove after http://drupal.org/node/512026. + } + catch (\Exception $e) { + // During testing the table is gone before this fires. + // @todo Use terminate() instead of __destruct(), see + // http://drupal.org/node/512026. } }