Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
content_translation.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Sep 2013 at 07:33 UTC
Updated:
29 Jul 2014 at 22:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pfrenssenHere is a test that shows the error message appearing during execution of
ContentTranslationUITest::assertOutdatedStatus().Comment #2
pfrenssenComment #4
gábor hojtsyWOAH! Sounds like both should be built using the same time (form time I guess).
Comment #5
pfrenssenRerolled the test. Mind that this is not intended to be the actual test for this bug, it just indicates the error message appearing when translations are marked as outdated.
Comment #7
pfrenssenThe way the 'changed' timestamps are updated in the node_field_data table is not consistent. If a node is saved in the original language, the timestamps of all languages are updated. When a translation is saved, only the timestamp of the translation is updated.
1. Create a new node in English. Only the english field data is saved.
2. Add a translation in Khmer. Only the timestamp of the Khmer translation is updated in node_field_data.
3. Resave the node in English. This time both the timestamps of the English and Khmer translations are updated again.
What is the correct one? I suppose only the updated translation should have its timestamp changed, otherwise you wouldn't know when exactly a translation was updated.
Comment #8
pfrenssenFrom NodeFormController::validate():
node_last_changed() retrieves the changed timestamp of the current translation, while getChangedTime() gets the one from LANGUAGE_UNDEFINED. So as soon as any translation is more recent than the default language this fails. We should allow to pass a language parameter to getChangedTime().
I also wonder why the constructor of EntityNG only stores the timestamps of the default language version, wouldn't it be more interesting to store these for all translations?
Comment #9
pfrenssenThis solves it, passing the langcode to getChangedTime(). If this is deemed a good approach we should extend this to the other properties.
Comment #11
gábor hojtsyI think the problem is when you have a node loaded, you have *all* the data on your loaded node. So when you go and re-save a node, even if you only changed a language that was not saved since, you may make another language outdated. So for that we are better off if we take max(all the changed dates we have), so we know the very latest modification time for all languages.
Comment #12
pfrenssenThis patch returns the most recent changed timestamp across all translations. I also added getChangedTime() to the NodeInterface as it was missing.
The tests are failing because the $this->values['changed'] array sometimes contains strings, and sometimes arrays :-/
For example if I inspect it in Entity::__construct() when running NodeTranslationTest:
and during CommentActionsTest:
Comment #13
berdirThis seems unecessary?
I don't think this is correct. The values shouldn't be directly accessed like this.
This method is now defined in EntityChangedInterface, this needs to be removed.
Comment #14
pfrenssenComment #15
pfrenssenI'm working on this but I could use some input. In this patch I have addressed the remarks from #13, but I have trouble retrieving the 'changed' timestamp of a particular translation. I assume I should use EntityNG::getTranslatedField() for it but this is always returning the timestamp of the default language, because the 'changed' property is not marked as translatable:
Say I have a node with English as the default language, and a Spanish translation. I want to retrieve the 'changed' timestamp from the Spanish translation, so I call it with
$this->getTranslatedField('changed', 'es'):I understand that the 'changed' property is not something which we should 'translate' but it should still be accessible in some way. This also is the case for other properties which are not strictly translatable but are translation-specific.
Comment #16
berdirI don't know what the correct fix here is, the problem is that changed is defined as not translatable but holds translatable values..
@plach?
Comment #17
pfrenssenThis problem does not occur any more since #2129039: Integrity constraint violation when translating body field got in. Marking this as a duplicate.