With a persistent entity cache, this means the following problem is very easy to replicate:
1) Create node A1
2) Translate node A1 as A2
The database is correct for both nodes (both tnids pointing to the nid for A1), but the load cache still contains the untranslated version of A1. If you view the translations for A2 you will see both nodes. If you view the translations for A1 you will see only A1.
If A1 is flushed from the cache at this point, things will resolve themselves, as the database is still correct.
If you edit and save A1 again before the cache is flushed, the untranslated state of A1 will be saved to the database.
Comment | File | Size | Author |
---|---|---|---|
#1 | drupal-translation_load_cache-1936942-1.patch | 2.61 KB | jweowu |
Comments
Comment #1
jweowu CreditAttribution: jweowu commentedComment #1.0
jweowu CreditAttribution: jweowu commentedLinked to example of persistent entity load cache
Comment #2
hefox CreditAttribution: hefox commentedLinking to issues in i18n and entitycache.
Confirming the bug, will test the patch.
Comment #3
hefox CreditAttribution: hefox commentedPatch works :)
Comment #4
jweowu CreditAttribution: jweowu commentedAre you happy to make this RTBC, or do you want additional eyes on it? (noting that it took more than a year to get your own response).
If you want more review from others, perhaps adding a note to that effect to your Related Issues would be of benefit?
Comment #5
hefox CreditAttribution: hefox commentedUpdated related issues with inquiry to review the core patch.
I'm not comfortable be the only review of a core patch (though note this did go through a qa process where it was tested on a sandbox then in a more production like environment).
Comment #6
ricovandevin CreditAttribution: ricovandevin commentedI've reviewed the patch from #1. It looks ok to me and it solves the problem we had with the combination of i18n and entitycache.
Do we make it RTBC or do we wait for another review?
Comment #7
mgiffordIt's been 2 years, so not sure that waiting for another review is a good idea.
Is this also a problem in Drupal 8?
Has anyone installed this in a production environment?
Is a SimplyTest.me environment like this sufficient to reproduce the problem with & without the patch?
Comment #8
jweowu CreditAttribution: jweowu commentedFWIW I wrote the patch, and have been using it in a production environment ever since.
For testing in SimplyTest.me, you only need to add entitycache. You don't need the i18n or variable modules.
Steps to reproduce/demonstrate (see also the original description for this issue).
* Enable core Content Translation (and Locale dependency), and contrib Entity Cache modules.
* Add a language: admin/config/regional/language/add
* Edit a content type: admin/structure/types/manage/page and under Publishing settings choose "Enabled, with translation".
* Add a page of that type: node/add/page, selecting a language.
* Go to the translate tab, and add a translation for the other language.
* Visit the translate tab for the new translation. You should see both nodes.
* Visit the original node, and then go to its translate tab.
Without the patch: The translation node is not shown; and if you now edit and save the original node (thus updating the database with the incorrect state) the translation relationship is permanently lost -- neither node knows about the other one.
With the patch: The translation node is shown, and the nodes can safely be edited and saved.
Comment #9
mgiffordI confirmed this here:
Without patch - http://s6c81708bf964fd1.s3.simplytest.me
With patch - http://s741d37b94635b55.s3.simplytest.me
I can confirm that the relationship is lost without the patch.
Comment #10
jweowu CreditAttribution: jweowu commentedI should really have mentioned how to observe the other fixes as well. It can be beneficial to add & enable the devel module as well, so that you can take a look at the tnid properties of the nodes.
In each case start with a translated node, clear the caches (admin/config/development/performance) and then view all nodes to ensure they are correctly loaded in entitycache.
1. Edit the source node and attempt to "Flag translations as outdated" (under the Translation settings fieldset).
Without the patch, this will have no effect on the translations, until the cache is cleared.
2. Delete the source node, and check the translations tab for one of the remaining nodes in the set.
Without the patch, there will now be no "Source" node in the translation set (as all the nodes will still have a tnid set to the nid of the deleted source node).
(As before, editing and saving one of the inconsistent nodes afterwards will make the incorrect state permanent.)
(The following has now been logged as #2367939: Translation sets should be 'removed' when they contain only one node).
As it happens, I've spotted another core bug while writing this.
translation_remove_from_set()
runs duringhook_node_delete()
which is before the node is removed from the database. That means that the "there is only one node left in the set" case will never occur (unless we are deleting the only node left in the set) because theCOUNT
query result will include the node being deleted. I'm 99% certain that the intention here was that if you reduce the set to a single node, it will revert to a tnid of zero (which is the same state as when you initially create a new un-translated node).n.b. The code for choosing a new translation node in the other branch is still okay, because in that case the
db_update()
query has set the tnid of the node being deleted to zero before it queries for other nodes with the original tnid, so that query doesn't include the node being deleted.I don't know whether to add a fix for that into this patch. I think I'd rather make that a separate issue. Perhaps if this one gets committed, we could then quickly roll a patch for this other issue and get it reviewed as well.
Comment #11
ricovandevin CreditAttribution: ricovandevin commentedI agree on the status of RTBC for this issue. Please commit this patch.
Comment #14
jweowu CreditAttribution: jweowu commentedThat seemed random. Is the testbot now automatically re-testing RTBC patches after core commits?
I'm assuming a false-positive, but I may have requested the re-test too soon to get a different result.
Comment #15
mgiffordComment #17
jweowu CreditAttribution: jweowu commentedWhat the heck is going on with the test bot? This is really annoying. It's hard enough to get Drupal 7 bugs looked at, without RTBC patches being arbitrarily marked as failures like this.
Comment #19
jweowu CreditAttribution: jweowu commentedFixing the status.
Comment #22
jweowu CreditAttribution: jweowu commentedAnyone know offhand if there's an existing d.o issue for this testbot problem?
Comment #23
dcam CreditAttribution: dcam commented@jweowu
See #2246867: Intermittent "test did not complete due to a fatal error" failures when testing Drupal 7 patches or the work-around issue #2319997: Don't automatically retest Drupal 7 core RTBC patches.
Comment #24
jweowu CreditAttribution: jweowu commentedMuch appreciated, dcam.
Comment #25
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks! As far as I can see, this doesn't affect Drupal 8.
Yeah, a separate issue for that sounds like a good idea.
Comment #27
jweowu CreditAttribution: jweowu commentedThanks David.
I've logged the related issue as #2367939: Translation sets should be 'removed' when they contain only one node.