diff --git a/core/includes/file.inc b/core/includes/file.inc index ee707e3439f..5c1ebde7fec 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -366,16 +366,15 @@ function file_stream_wrapper_uri_normalize($uri) { * (Drupal\Core\StreamWrapper\PrivateStream). */ function file_stream_wrapper_get_instance_by_uri($uri) { - $scheme = file_uri_scheme($uri); - $class = file_stream_wrapper_get_class($scheme); - if (class_exists($class)) { - $instance = new $class(); - $instance->setUri($uri); - return $instance; - } - else { - return FALSE; + if ($scheme = file_uri_scheme($uri)) { + $class = file_stream_wrapper_get_class($scheme); + if (class_exists($class)) { + $instance = new $class(); + $instance->setUri($uri); + return $instance; + } } + return FALSE; } /** diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 4700203d971..0fb4e398e35 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -856,24 +856,8 @@ abstract class TestBase { file_prepare_directory($this->translation_files_directory, FILE_CREATE_DIRECTORY); $this->generatedTestFiles = FALSE; - // Create and set new configuration directories. The child site - // uses drupal_valid_test_ua() to adjust the config directory paths to - // a test-prefix-specific directory within the public files directory. - // @see config_get_config_directory() - $GLOBALS['config_directories'] = array(); - $this->configDirectories = array(); - include_once DRUPAL_ROOT . '/core/includes/install.inc'; - foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $type) { - // Assign the relative path to the global variable. - $path = 'simpletest/' . substr($this->databasePrefix, 10) . '/config_' . $type; - $GLOBALS['config_directories'][$type]['path'] = $path; - // Ensure the directory can be created and is writeable. - if (!install_ensure_config_directory($type)) { - return FALSE; - } - // Provide the already resolved path for tests. - $this->configDirectories[$type] = $this->originalFileDirectory . '/' . $path; - } + // Create and set new configuration directories. + $this->prepareConfigDirectories(); // Reset and create a new service container. $this->container = new ContainerBuilder(); @@ -896,6 +880,32 @@ abstract class TestBase { $this->setupEnvironment = TRUE; } + /** + * Create and set new configuration directories. + * + * The child site uses drupal_valid_test_ua() to adjust the config directory + * paths to a test-prefix-specific directory within the public files + * directory. + * + * @see config_get_config_directory() + */ + protected function prepareConfigDirectories() { + $GLOBALS['config_directories'] = array(); + $this->configDirectories = array(); + include_once DRUPAL_ROOT . '/core/includes/install.inc'; + foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $type) { + // Assign the relative path to the global variable. + $path = 'simpletest/' . substr($this->databasePrefix, 10) . '/config_' . $type; + $GLOBALS['config_directories'][$type]['path'] = $path; + // Ensure the directory can be created and is writeable. + if (!install_ensure_config_directory($type)) { + return FALSE; + } + // Provide the already resolved path for tests. + $this->configDirectories[$type] = $this->originalFileDirectory . '/' . $path; + } + } + /** * Rebuild drupal_container(). * diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php index a62eb90f201..dd6703bb699 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -134,10 +134,17 @@ abstract class UpgradePathTestBase extends WebTestBase { $this->variable_set('site_mail', 'simpletest@example.com'); drupal_set_time_limit($this->timeLimit); - $this->rebuildContainer(); $this->setup = TRUE; } + /** + * Overrides \Drupal\simpletest\TestBase::prepareConfigDirectories(). + */ + protected function prepareConfigDirectories() { + // The configuration directories are prepared as part of the first access to + // update.php. + } + /** * Specialized variable_set() that works even if the child site is not upgraded. * @@ -175,7 +182,13 @@ abstract class UpgradePathTestBase extends WebTestBase { protected function refreshVariables() { // No operation if the child has not been upgraded yet. if (!$this->upgradedSite) { - return parent::refreshVariables(); + global $conf; + cache('bootstrap')->delete('variables'); + $conf = variable_initialize(); + $container = drupal_container(); + if ($container->has('config.factory')) { + $container->get('config.factory')->reset(); + } } } @@ -195,6 +208,16 @@ abstract class UpgradePathTestBase extends WebTestBase { throw new Exception('Initial GET to update.php did not return HTTP 200 status.'); } + // Ensure that the first update screen appeared correctly. + if (!$this->assertFieldByXPath('//input[@type="submit"]')) { + throw new Exception('An error was encountered during the first access to update.php.'); + } + + // Initialize config directories and rebuild the service container after + // creating them in the first step. + parent::prepareConfigDirectories(); + $this->rebuildContainer(); + // Continue. $this->drupalPost(NULL, array(), t('Continue')); if (!$this->assertResponse(200)) { diff --git a/core/modules/user/user.install b/core/modules/user/user.install index cc0bfeba666..f0b921c5020 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -949,7 +949,7 @@ function user_update_8014() { 'module' => array( 'description' => 'The name of the module declaring the variable.', 'type' => 'varchar', - 'length' => 255, + 'length' => 204, 'not null' => TRUE, 'default' => '', ),