diff -u b/core/lib/Drupal/Core/Entity/EntityChangedInterface.php b/core/lib/Drupal/Core/Entity/EntityChangedInterface.php --- b/core/lib/Drupal/Core/Entity/EntityChangedInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityChangedInterface.php @@ -22,8 +22,7 @@ interface EntityChangedInterface { /** - * Returns the timestamp of the last entity change of the current - * translation. + * Returns the timestamp of the last entity change for current translation. * * @return int * The timestamp of the last entity save operation. diff -u b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php --- b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/ChangedItem.php @@ -52,9 +52,9 @@ if ($this->getFieldDefinition()->isTranslatable()) { $original = $original->getTranslation($entity->language()->getId()); } - // If the timestamp has not been set explicitly auto detect a modification - // of the current translation and set the timestamp if needed. - // An example of setting the timestamp explicitly is + // If the timestamp has not been set explicitly auto detect a + // modification of the current translation and set the timestamp if + // needed. An example of setting the timestamp explicitly is // \Drupal\content_translation\ContentTranslationMetadataWrapperInterface::setChangedTime() if ($this->value == $original->{$field_name}->value) { foreach ($entity->getFieldDefinitions() as $other_field_definition) { diff -u b/core/modules/comment/src/CommentStatistics.php b/core/modules/comment/src/CommentStatistics.php --- b/core/modules/comment/src/CommentStatistics.php +++ b/core/modules/comment/src/CommentStatistics.php @@ -126,7 +126,6 @@ } // Default to REQUEST_TIME when entity does not have a changed property. $last_comment_timestamp = REQUEST_TIME; - // @todo make comment statistics language aware. if ($entity instanceof EntityChangedInterface) { $last_comment_timestamp = $entity->getChangedTimeAcrossTranslations(); } diff -u b/core/modules/content_translation/src/ContentTranslationMetadataWrapperInterface.php b/core/modules/content_translation/src/ContentTranslationMetadataWrapperInterface.php --- b/core/modules/content_translation/src/ContentTranslationMetadataWrapperInterface.php +++ b/core/modules/content_translation/src/ContentTranslationMetadataWrapperInterface.php @@ -108,8 +108,7 @@ public function setCreatedTime($timestamp); /** - * Returns the timestamp of the last entity change of the current - * translation. + * Returns the timestamp of the last entity change from current translation. * * @return int * The timestamp of the last entity save operation. diff -u b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php --- b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php @@ -400,8 +400,6 @@ $langcode = $language->getId(); - // Set the custom translatable field and the revision log to predictable - // values containing a counter. $edit = array( $this->fieldName . '[0][value]' => $this->randomString(), ); @@ -415,9 +413,9 @@ ); if ($i > 1) { - // Because the base of this test created the translations - // without a sleep command, the changed timestamps might not differ - // until the second run of that loop. + // Because the base of this test created the translations without a + // sleep command, the changed timestamps might not differ until the + // second run of that loop. $timestamps = array(); foreach ($entity->getTranslationLanguages() as $language) { $next_timestamp = $entity->getTranslation($language->getId()) diff -u b/core/modules/node/node.module b/core/modules/node/node.module --- b/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -741,7 +741,7 @@ * @param $nid * The ID of a node. * @param string $langcode - * (optional) The language the node has been last modified in. If omitted the + * (optional) The language to get the last changed time for. If omitted the * last changed time across all translations will be returned. * * @return string diff -u b/core/modules/node/src/Tests/NodeSaveTest.php b/core/modules/node/src/Tests/NodeSaveTest.php --- b/core/modules/node/src/Tests/NodeSaveTest.php +++ b/core/modules/node/src/Tests/NodeSaveTest.php @@ -130,9 +130,9 @@ $node->save(); $node = $this->drupalGetNodeByTitle($edit['title'], TRUE); $this->assertEqual($node->getCreatedTime(), 979534800, 'Updating a node uses user-set "created" timestamp.'); - // Allowing setting changed timestamps is required see + // Allowing setting changed timestamps is required, see // Drupal\content_translation\ContentTranslationMetadataWrapper::setChangedTime($timestamp) - // for example + // for example. $this->assertEqual($node->getChangedTime(), 280299600, 'Updating a node uses user-set "changed" timestamp.'); } diff -u b/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php b/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php --- b/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php +++ b/core/modules/system/src/Tests/Entity/ContentEntityChangedTest.php @@ -58,8 +58,8 @@ 'Changed time of original language is valid.' ); - // We can't assert equality here because the created time is set to - // REQUEST_TIME while instances of ChangedTestItem use the current + // We can't assert equality here because the created time is set to the + // request time, while instances of ChangedTestItem use the current // timestamp every time. $this->assertTrue( ($entity->getChangedTime() >= $entity->get('created')->value) && @@ -148,10 +148,9 @@ 'Changed time of the German translation did not change.' ); - // Final state: changed time of original language (en) is newer than - // the changed time of the German translation. - // Now try some entity queries. - + // Current state: changed time of original language (en) is newer than the + // changed time of the German translation. Test that entity queries work as + // expected. $entity_query_service = $this->container->get('entity.query'); $query = $entity_query_service->get('entity_test_mul_changed'); @@ -175,7 +174,7 @@ $this->assertTrue( empty($ids), - 'There\'s no original entity stored using the changed time of the German translation.' + 'There\'s no original entity stored having the changed time of the German translation.' ); $query = $entity_query_service->get('entity_test_mul_changed'); @@ -199,7 +198,7 @@ $this->assertTrue( empty($ids), - 'There\'s no German translation stored using the changed time of the original language.' + 'There\'s no German translation stored having the changed time of the original language.' ); $query = $entity_query_service->get('entity_test_mul_changed'); @@ -255,8 +254,8 @@ 'Changed time of original language is valid.' ); - // We can't assert equality here because the created time is set to - // REQUEST_TIME while instances of ChangedTestItem use the current + // We can't assert equality here because the created time is set to the + // request time while instances of ChangedTestItem use the current // timestamp every time. $this->assertTrue( ($entity->getChangedTime() >= $entity->get('created')->value) && @@ -274,7 +273,7 @@ $entity->setNewRevision(); // Save entity without any changes but create new revision. $entity->save(); - + // A new revision without any changes should not set a new changed time. $this->assertEqual( $entity->getChangedTime(), $changed_en, 'Changed time of original language did not change.' diff -u b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php --- b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php @@ -33,6 +33,10 @@ parent::preSave(); if ($this->value == REQUEST_TIME) { + // During a test the request time is immutable. To allow tests of the + // algorithm of + // Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem::preSave() we need + // to set a real time value here. $this->value = time(); } }