diff --git a/core/includes/update.inc b/core/includes/update.inc index d5818d005aaab967209d363737ba7687d483d6ec..521773703cf7d7a9152a1c29db470382cfb859d8 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -397,7 +397,14 @@ function update_get_update_list() { if ($update > $schema_version) { // The description for an update comes from its Doxygen. $func = new ReflectionFunction($module . '_update_' . $update); - $description = str_replace(["\n", '*', '/'], '', $func->getDocComment()); + $patterns = [ + '/^\s*[\/*]*/', + '/(\n\s*\**)(.*)/', + '/\/$/', + '/^\s*/', + ]; + $replacements = ['', '$2', '', '']; + $description = preg_replace($patterns, $replacements, $func->getDocComment()); $ret[$module]['pending'][$update] = "$update - $description"; if (!isset($ret[$module]['start'])) { $ret[$module]['start'] = $update; diff --git a/core/modules/system/tests/modules/update_test_description/update_test_description.info.yml b/core/modules/system/tests/modules/update_test_description/update_test_description.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..be1e007cb51121150a18a87e05b0f214798d26f9 --- /dev/null +++ b/core/modules/system/tests/modules/update_test_description/update_test_description.info.yml @@ -0,0 +1,5 @@ +name: Update test description +type: module +description: Support module for update testing. +package: Testing +version: VERSION diff --git a/core/modules/system/tests/modules/update_test_description/update_test_description.install b/core/modules/system/tests/modules/update_test_description/update_test_description.install new file mode 100644 index 0000000000000000000000000000000000000000..1ed00ccad30b7c046bdacd2481041203fb10585c --- /dev/null +++ b/core/modules/system/tests/modules/update_test_description/update_test_description.install @@ -0,0 +1,19 @@ +<?php + +/** + * @file + * Install, update and uninstall functions for the update_test_descriptions module. + */ + +/** + * Update test of slash in description and/or. + */ +function update_test_description_update_8001() { +} + +/** + * Update test with multiline description, the quick brown fox jumped over the + * lazy dog. + */ +function update_test_description_update_8002() { +} diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateDescriptionTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateDescriptionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e9474619569e1dfcd0467ac27570b5ec4e4d806a --- /dev/null +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateDescriptionTest.php @@ -0,0 +1,70 @@ +<?php + +namespace Drupal\Tests\system\Functional\UpdateSystem; + +use Drupal\Core\Database\Database; +use Drupal\Core\Url; +use Drupal\Tests\BrowserTestBase; + +/** + * Tests the display of the description for hook_update(). + * + * @group Update + */ +class UpdateDescriptionTest extends BrowserTestBase { + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + + /** + * Tests displayed description. + */ + public function testDescription() { + $user = $this->drupalCreateUser([ + 'administer software updates', + 'access site in maintenance mode', + ]); + $this->drupalLogin($user); + + $connection = Database::getConnection(); + // Set the schema version. + $connection->merge('key_value') + ->condition('collection', 'system.schema') + ->condition('name', 'update_test_description') + ->fields([ + 'collection' => 'system.schema', + 'name' => 'update_test_description', + 'value' => 'i:8000;', + ]) + ->execute(); + // Update core.extension. + $extensions = $connection->select('config') + ->fields('config', ['data']) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute() + ->fetchField(); + $extensions = unserialize($extensions); + $extensions['module']['update_test_description'] = 8000; + $connection->update('config') + ->fields([ + 'data' => serialize($extensions), + ]) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute(); + + // Go to the update page. + $update_url = Url::fromRoute('system.db_update'); + + $this->drupalGet($update_url); + $this->clickLink(t('Continue')); + + // Check that the description is displayed correctly. + $this->assertSession()->responseContains('8001 - Update test of slash in description and/or.'); + $this->assertSession()->responseContains('8002 - Update test with multiline description, the quick brown fox jumped over the lazy dog.'); + } + +} diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php index fee94d95054ac02c1e579a5cf5c6209c36822ea8..bef4c112c50e8264755e2a3b1608926406290895 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateFailingTest.php @@ -76,8 +76,8 @@ public function testPostUpdate() { */ protected function doSelectionTest() { // First update, should not be run since this module's update hooks fail. - $this->assertRaw('8001 - This update will fail.'); - $this->assertRaw('8002 - A further update.'); + $this->assertSession()->responseContains('8001 - This update will fail.'); + $this->assertSession()->responseContains('8002 - A further update'); $this->assertSession()->assertEscaped("First update, should not be run since this module's update hooks fail."); } diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php index 8cfa3d33bbeefee2b1566c2206e108fe6d3d9980..6c065454e95de66d9df7bf09068b31972b02cd4a 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php @@ -75,7 +75,7 @@ protected function setUp(): void { protected function doSelectionTest() { // Ensure that normal and post_update updates are merged together on the // selection page. - $this->assertRaw('<ul><li>8001 - Normal update_N() function. </li><li>First update.</li><li>Second update.</li><li>Test0 update.</li><li>Test1 update.</li><li>Testing batch processing in post updates update.</li></ul>'); + $this->assertSession()->responseContains('<ul><li>8001 - Normal update_N() function.</li><li>First update.</li><li>Second update.</li><li>Test0 update.</li><li>Test1 update.</li><li>Testing batch processing in post updates update.</li></ul>'); } /**