diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/MailUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/MailUpgradePathTest.php index fe9dda2..d52fd22 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/MailUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/MailUpgradePathTest.php @@ -36,7 +36,13 @@ function testMailSystemUpgrade() { 'maillog' => 'MaillogMailSystem', )); - $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + // Perform the upgrade without redirecting to check for pending updates, + // so that we can test for user warnings. + $this->performUpgrade(TRUE, FALSE); + // Ensure the user is informed about mail backends that need updating. + $this->assertText('The following mail backends need to be re-configured: MaillogMailSystem', 'User notified about outdated mail backends.'); + $this->assertTrue($this->checkPendingUpdates(), 'The upgrade was completed successfully.'); + // Get the new mailer definitions. $mail_system = config('system.mail')->get('interface'); 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 c4dda65..e3e2c77 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -197,10 +197,12 @@ protected function refreshVariables() { * * @param $register_errors * Register the errors during the upgrade process as failures. + * @param $check_pending_updates + * Check to make sure no updates are outstanding after an upgrade. * @return * TRUE if the upgrade succeeded, FALSE otherwise. */ - protected function performUpgrade($register_errors = TRUE) { + protected function performUpgrade($register_errors = TRUE, $check_pending_updates = TRUE) { // Load the first update screen. $this->getUpdatePhp(); @@ -252,7 +254,23 @@ protected function performUpgrade($register_errors = TRUE) { throw new Exception('Errors during update process.'); } - // Check if there still are pending updates. + if ($check_pending_updates) { + return $this->checkPendingUpdates(); + } + + return TRUE; + } + + /** + * Checks that no updates are pending at the end of an upgrade. + * + * @return bool + * TRUE if there are no pending updates, FALSE if not. + * + * @throws \Exception + */ + protected function checkPendingUpdates() { + // Check if there are still pending updates. $this->getUpdatePhp(); $this->drupalPost(NULL, array(), t('Continue')); if (!$this->assertText(t('No pending updates.'), 'No pending updates at the end of the update process.')) { diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 46c3d9b..b701cbf 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2221,8 +2221,10 @@ function system_update_8046() { function system_update_8047() { // Update any mail interfaces to their Drupal 8 equivalents. $old_mail_system_settings = update_variable_get('mail_system'); - $new_mail_system_settings = array(); + if ($old_mail_system_settings) { + $new_mail_system_settings = array(); + foreach ($old_mail_system_settings as $key => $mailer_class) { // Update old class name to PSR-0. if ($mailer_class == 'DefaultMailSystem') { @@ -2234,16 +2236,18 @@ function system_update_8047() { unset($old_mail_system_settings[$key]); } } + // Warn about non-core classes which may need to be updated. + drupal_set_message(t('The following mail backends need to be re-configured: @list', array('@list' => implode(', ', $old_mail_system_settings))), 'warning'); + + $new_mail_system_settings += $old_mail_system_settings; + // Save the updated variable, and let update_variables_to_config convert it. + if ($new_mail_system_settings) { + update_variable_set('mail_system', $new_mail_system_settings); + update_variables_to_config('system.mail', array( + 'mail_system' => 'interface', + )); + } } - - // Warn about non-core classes which may need updated. - drupal_set_message('The following mail backends need to be re-configured: @list', implode(', ', $old_mail_system_settings)); - $new_mail_system_settings += $old_mail_system_settings; - // Save the updated variable, and let update_variables_to_config convert it. - variable_set('mail_system', $new_mail_system_settings); - update_variables_to_config('system.mail', array( - 'mail_system' => 'interface', - )); } /**