diff --git a/core/modules/block/block.install b/core/modules/block/block.install index 3c1755f..59e6814 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -202,13 +202,15 @@ function block_update_8007() { 'info', 'revision_id', 'langcode', - 'type' + 'type', + 'changed', )); $revision_insert = db_insert('custom_block_revision')->fields(array( 'id', 'revision_id', 'log', - 'info' + 'info', + 'changed', )); foreach ($results as $block) { $custom_block = array( @@ -217,13 +219,15 @@ function block_update_8007() { 'info' => $block->info, 'revision_id' => $block->bid, 'langcode' => Language::LANGCODE_NOT_SPECIFIED, - 'type' => 'basic' + 'type' => 'basic', + 'changed' => REQUEST_TIME, ); $revision = array( 'id' => $block->bid, 'revision_id' => $block->bid, 'info' => $block->info, - 'log' => 'Initial value from 7.x to 8.x upgrade' + 'log' => 'Initial value from 7.x to 8.x upgrade', + 'changed' => REQUEST_TIME, ); $block_insert->values($custom_block); $revision_insert->values($revision); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php index b74de5c..3efb47d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php @@ -84,6 +84,8 @@ public function testDeterminingChanges() { $block->info->value = 'updated'; $block->save(); + $this->assertTrue($block->getChangedTime(), 'Changed time maintained.'); + // The hook implementations custom_block_test_custom_block_presave() and // custom_block_test_custom_block_update() determine changes and change the // title. diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php index bde6f60..fbba3ad 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php @@ -60,6 +60,32 @@ public function testBlockUpgradeTitleLength() { // Confirm that the custom block cannot be created with title longer than // the maximum number of characters. $this->assertText('Title cannot be longer than 255 characters'); + + $block = $this->createCustomBlock(); + $this->assertTrue($block->getChangedTime(), 'Changed time maintained.'); } + /** + * Creates a custom block. + * + * @param string $title + * (optional) Title of block. When no value is given uses a random name. + * Defaults to FALSE. + * @param string $bundle + * (optional) Bundle name. Defaults to 'basic'. + * + * @return Drupal\custom_block\Entity\CustomBlock + * Created custom block. + */ + protected function createCustomBlock($title = FALSE, $bundle = 'basic') { + $title = ($title ? : $this->randomName()); + if ($custom_block = entity_create('custom_block', array( + 'info' => $title, + 'type' => $bundle, + 'langcode' => 'en' + ))) { + $custom_block->save(); + } + return $custom_block; + } }