diff --git a/core/lib/Drupal/Core/DependencyInjection/UpdateServiceProvider.php b/core/lib/Drupal/Core/DependencyInjection/UpdateServiceProvider.php
deleted file mode 100644
index 32ad9b7..0000000
--- a/core/lib/Drupal/Core/DependencyInjection/UpdateServiceProvider.php
+++ /dev/null
@@ -1,64 +0,0 @@
-register('lock', 'Drupal\Core\Lock\NullLockBackend');
-
- // Prevent config from being accessed via a cache wrapper by removing
- // any existing definition and setting an alias to the actual storage.
- $container->removeDefinition('config.storage');
- $container->setAlias('config.storage', 'config.storage.active');
-
- $container
- ->register('cache_factory', 'Drupal\Core\Cache\MemoryBackendFactory');
- $container
- ->register('router.builder', 'Drupal\Core\Routing\RouteBuilderStatic');
-
- $container->register('theme_handler', 'Drupal\Core\Extension\ThemeHandler')
- ->addArgument(new Reference('config.factory'))
- ->addArgument(new Reference('module_handler'))
- ->addArgument(new Reference('state'))
- ->addArgument(new Reference('info_parser'));
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function alter(ContainerBuilder $container) {
- // Ensure that URLs generated for the home and admin pages don't have
- // 'update.php' in them.
- $request = Request::createFromGlobals();
- $definition = $container->getDefinition('url_generator');
- $definition->addMethodCall('setBasePath', array(str_replace('/core', '', $request->getBasePath()) . '/'));
- // We need to set the script path to an empty string since the value
- // determined by \Drupal\Core\Routing\UrlGenerator::setRequest() is invalid
- // once '/core' has been removed from the base path.
- $definition->addMethodCall('setScriptPath', array(''));
- }
-
-}
diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php
index 0e11e1e..2526a18 100644
--- a/core/modules/system/src/Controller/DbUpdateController.php
+++ b/core/modules/system/src/Controller/DbUpdateController.php
@@ -107,24 +107,23 @@ public static function create(ContainerInterface $container) {
public function handle($op, Request $request) {
require_once DRUPAL_ROOT . '/core/includes/install.inc';
require_once DRUPAL_ROOT . '/core/includes/update.inc';
- require_once DRUPAL_ROOT . '/core/modules/system/system.install';
+
+ drupal_load_updates();
+ update_fix_compatibility();
+
+ if ($request->query->get('continue')) {
+ $_SESSION['update_ignore_warnings'] = TRUE;
+ }
$regions = array();
$requirements = update_check_requirements();
$severity = drupal_requirements_severity($requirements);
- if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING) {
+ if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($_SESSION['update_ignore_warnings']))) {
$regions['sidebar_first'] = $this->updateTasksList('requirements');
- $output = $this->requirementsPage($severity, $requirements);
+ $output = $this->requirements($severity, $requirements);
}
else {
- require_once DRUPAL_ROOT . '/core/includes/batch.inc';
- drupal_load_updates();
-
- update_fix_compatibility();
-
switch ($op) {
- // update.php ops.
-
case 'selection':
$regions['sidebar_first'] = $this->updateTasksList('selection');
$output = $this->selection();
@@ -147,6 +146,7 @@ public function handle($op, Request $request) {
// Regular batch ops : defer to batch processing API.
default:
+ require_once DRUPAL_ROOT . '/core/includes/batch.inc';
$regions['sidebar_first'] = $this->updateTasksList('run');
$output = _batch_page($request);
break;
@@ -425,6 +425,7 @@ protected function results() {
}
unset($_SESSION['update_results']);
unset($_SESSION['update_success']);
+ unset($_SESSION['update_ignore_warnings']);
return $build;
}
@@ -435,11 +436,14 @@ protected function results() {
* @return array
* A render array.
*/
- public function requirementsPage(array $requirements) {
+ public function requirements($severity, array $requirements) {
+ $options = $severity == REQUIREMENT_WARNING ? array('continue' => 1) : array();
+ $try_again_url = $this->url('system.db_update', $options);
+
$build['status_report'] = array(
'#theme' => 'status_report',
'#requirements' => $requirements,
- '#suffix' => $this->t('Check the messages and try again.', array('@url' => $this->url('system.db_update')))
+ '#suffix' => $this->t('Check the messages and try again.', array('@url' => $try_again_url))
);
$build['#title'] = $this->t('Requirements problem');
@@ -488,9 +492,7 @@ protected function triggerBatch(Request $request) {
$_SESSION['maintenance_mode'] = $maintenance_mode;
}
if (empty($_SESSION['maintenance_mode'])) {
- if (db_table_exists('state')) {
- $this->state->set('system.maintenance_mode', TRUE);
- }
+ $this->state->set('system.maintenance_mode', TRUE);
}
$start = $this->getModuleUpdates();
@@ -550,10 +552,6 @@ protected function triggerBatch(Request $request) {
* A list of all the operations that had not been completed by the batch API.
*/
public static function batchFinished($success, $results, $operations) {
- // Clear the caches in case the data has been updated.
- $GLOBALS['conf']['update_service_provider_overrides'] = FALSE;
- \Drupal::service('kernel')->updateModules(\Drupal::moduleHandler()->getModuleList());
-
// No updates to run, so caches won't get flushed later. Clear them now.
drupal_flush_all_caches();
@@ -580,7 +578,7 @@ protected function helpfulLinks() {
'title' => $this->t('Front page'),
'href' => '',
);
- if (user_access('access administration pages')) {
+ if ($this->account->hasPermission('access administration pages')) {
$links['admin-pages'] = array(
'title' => $this->t('Administration pages'),
'href' => 'admin',
diff --git a/core/modules/system/src/Tests/Update/InvalidUpdateHook.php b/core/modules/system/src/Tests/Update/InvalidUpdateHook.php
index 460d03f..1587c43 100644
--- a/core/modules/system/src/Tests/Update/InvalidUpdateHook.php
+++ b/core/modules/system/src/Tests/Update/InvalidUpdateHook.php
@@ -48,7 +48,7 @@ function setUp() {
parent::setUp();
require_once DRUPAL_ROOT . '/core/includes/update.inc';
- $this->update_url = $GLOBALS['base_url'] . '/core/update.php';
+ $this->update_url = $GLOBALS['base_url'] . '/update.php';
$this->update_user = $this->drupalCreateUser(array('administer software updates'));
}
@@ -56,7 +56,7 @@ function testInvalidUpdateHook() {
// Confirm that a module with hook_update_8000() cannot be updated.
$this->drupalLogin($this->update_user);
$this->drupalGet($this->update_url);
- $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
+ $this->clickLink(t('Continue'));
$this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.'));
}
diff --git a/core/modules/system/src/Tests/Update/UpdateScriptTest.php b/core/modules/system/src/Tests/Update/UpdateScriptTest.php
index cd92191..c709cdd 100644
--- a/core/modules/system/src/Tests/Update/UpdateScriptTest.php
+++ b/core/modules/system/src/Tests/Update/UpdateScriptTest.php
@@ -36,30 +36,8 @@ public static function getInfo() {
function setUp() {
parent::setUp();
- $this->update_url = $GLOBALS['base_url'] . '/core/update.php';
- $this->update_user = $this->drupalCreateUser(array('administer software updates'));
- }
-
- /**
- * Tests that updates from schema versions prior to 8000 are prevented.
- */
- function testInvalidMigration() {
- // Mock a D7 system table so that the schema value of the system module
- // can be retrieved.
- db_create_table('system', $this->getSystemSchema());
- // Assert that the table exists.
- $this->assertTrue(db_table_exists('system'), 'The table exists.');
- // Insert a value for the system module.
- db_insert('system')
- ->fields(array(
- 'name' => 'system',
- 'schema_version' => 7000,
- ))
- ->execute();
- $system_schema = db_query('SELECT schema_version FROM {system} WHERE name = :system', array(':system' => 'system'))->fetchField();
- $this->drupalGet($this->update_url, array('external' => TRUE));
- $text = 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must migrate your site to Drupal 8 first.';
- $this->assertRaw($text, 'Updates from schema versions prior to 8000 are prevented.');
+ $this->update_url = $GLOBALS['base_url'] . '/update.php';
+ $this->update_user = $this->drupalCreateUser(array('administer software updates', 'access site in maintenance mode'));
}
/**
@@ -102,7 +80,7 @@ function testRequirements() {
// If there are no requirements warnings or errors, we expect to be able to
// go through the update process uninterrupted.
$this->drupalGet($this->update_url, array('external' => TRUE));
- $this->drupalPostForm(NULL, array(), t('Continue'));
+ $this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
$this->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared when there were no requirements warnings or errors.');
@@ -119,8 +97,8 @@ function testRequirements() {
$this->assertText('This is a requirements warning provided by the update_script_test module.');
$this->clickLink('try again');
$this->assertNoText('This is a requirements warning provided by the update_script_test module.');
- $this->drupalPostForm(NULL, array(), t('Continue'));
- $this->drupalPostForm(NULL, array(), 'Apply pending updates');
+ $this->clickLink(t('Continue'));
+ $this->clickLink(t('Apply pending updates'));
$this->assertText(t('The update_script_test_update_8001() update was executed successfully.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
$this->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after resolving a requirements warning and applying updates.');
@@ -130,7 +108,7 @@ function testRequirements() {
$this->assertText('This is a requirements warning provided by the update_script_test module.');
$this->clickLink('try again');
$this->assertNoText('This is a requirements warning provided by the update_script_test module.');
- $this->drupalPostForm(NULL, array(), t('Continue'));
+ $this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'), 'End of update process was reached.');
// Confirm that all caches were cleared.
$this->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after applying updates and re-running the script.');
@@ -165,7 +143,8 @@ function testThemeSystem() {
function testNoUpdateFunctionality() {
// Click through update.php with 'administer software updates' permission.
$this->drupalLogin($this->update_user);
- $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
+ $this->drupalGet($this->update_url, array('external' => TRUE));
+ $this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'));
$this->assertNoLink('Administration pages');
$this->assertNoLinkByHref('update.php', 0);
@@ -175,7 +154,8 @@ function testNoUpdateFunctionality() {
// Click through update.php with 'access administration pages' permission.
$admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages'));
$this->drupalLogin($admin_user);
- $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
+ $this->drupalGet($this->update_url, array('external' => TRUE));
+ $this->clickLink(t('Continue'));
$this->assertText(t('No pending updates.'));
$this->assertLink('Administration pages');
$this->assertNoLinkByHref('update.php', 1);
@@ -197,8 +177,9 @@ function testSuccessfulUpdateFunctionality() {
// Click through update.php with 'administer software updates' permission.
$this->drupalLogin($this->update_user);
- $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
- $this->drupalPostForm(NULL, array(), t('Apply pending updates'));
+ $this->drupalGet($this->update_url, array('external' => TRUE));
+ $this->clickLink(t('Continue'));
+ $this->clickLink(t('Apply pending updates'));
// Verify that updates were completed successfully.
$this->assertText('Updates were attempted.');
@@ -229,10 +210,11 @@ function testSuccessfulUpdateFunctionality() {
// Click through update.php with 'access administration pages' and
// 'access site reports' permissions.
- $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports'));
+ $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode'));
$this->drupalLogin($admin_user);
- $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
- $this->drupalPostForm(NULL, array(), t('Apply pending updates'));
+ $this->drupalGet($this->update_url, array('external' => TRUE));
+ $this->clickLink(t('Continue'));
+ $this->clickLink(t('Apply pending updates'));
$this->assertText('Updates were attempted.');
$this->assertLink('logged');
$this->assertLink('Administration pages');
diff --git a/core/modules/system/src/Tests/Update/UpdatesWith7x.php b/core/modules/system/src/Tests/Update/UpdatesWith7x.php
index 4d85f9d..1350df5 100644
--- a/core/modules/system/src/Tests/Update/UpdatesWith7x.php
+++ b/core/modules/system/src/Tests/Update/UpdatesWith7x.php
@@ -42,7 +42,7 @@ public static function getInfo() {
function setUp() {
parent::setUp();
require_once DRUPAL_ROOT . '/core/includes/update.inc';
- $this->update_url = $GLOBALS['base_url'] . '/core/update.php';
+ $this->update_url = $GLOBALS['base_url'] . '/update.php';
$this->update_user = $this->drupalCreateUser(array('administer software updates'));
}
@@ -57,7 +57,8 @@ function testWith7x() {
// Click through update.php with 'administer software updates' permission.
$this->drupalLogin($this->update_user);
- $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE));
+ $this->drupalGet($this->update_url, array('external' => TRUE));
+ $this->clickLink(t('Continue'));
$this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.'));
}
}