Situation: run entity_translation_upgrade using post beta6 latest dev entity_translation_upgrade for a content translation node using the GUI, OR the drush plugin for that matter #1800158: Entity Translation Upgrade, drush extension.
entity_translation_upgrade_do needs to automatically create the entity_translation row for the source language in entity_translation
example:
select * from entity_translation where entity_id = 12345;
PRIOR to patch:
Entity_type entity_id language source uid status translate created
node 12345 fr en 99 1 0 1499977756
select * from entity_translation where entity_id = 12345;
AFTER PATCH and redoing the entity_translation_upgrade for that content (restore backup and rerun ET_upgrade)
Entity_type entity_id language source uid status translate created
node 12345 en fr 1 1 0 1499977756
node 12345 fr en 99 1 0 1499977756
Without this patch, after an entity_translation upgrade the french fields show up on the /en/node/12345/edit
simply clicking translate will add this missing row, but best if this is correctly fixed during the actual entity_translation upgrade because I don't want our users to have to click several thousand times the translate link.
SOLUTION: apply latest patch below PRIOR to running entity_translation_upgrade for a node translation to entity_translation upgrade, we recommend that we commit this fix asap.
Comments
Comment #2
joseph.olstadComment #3
joseph.olstadComment #4
joseph.olstadComment #5
joseph.olstadComment #6
joseph.olstadComment #7
gdaw CreditAttribution: gdaw as a volunteer commentedThanks a bunch!
RTBC +1
Comment #8
gdaw CreditAttribution: gdaw as a volunteer commentedComment #9
joseph.olstadComment #10
joseph.olstadComment #11
dsutter CreditAttribution: dsutter as a volunteer commentedWorks for me.
RTBC +1
Comment #12
joseph.olstadPLEASE COMMIT! Lets get this in right away, plan for a 1.0 release!
Comment #13
stefanos.petrakis@gmail.comHi all and thanks for the report, patch-work and feedback.
I think that that piece of code reads a bit inconsistent, as in:
As an alternative option, this code (which exists inside the
updateTranslations()
function) runs an explicit check on thedata
property:This seems to solve the reported problem as well, any opinions against this?
And at least a test for this scenario should be included in the patch, something along those lines:
Would anyone of the people involved so far care to provide an updated patch with the test?
Comment #14
joseph.olstadFunny you mention that @stefanos.petrakis , I grabbed that code VERBATIM from 7.x-1.x dev of entity_translation
so if it's needs work in my patch, then entity_translation 7.x-1.x dev needs work.
see this screenshot line 231 of entity_translation.admin.inc :
now look at the patch:
SAME=SAME
it works, passes testing, and conforms exactly to the entity_translation module, copied verbatim.
The code is fired when the 'translate' link is clicked, that's where I copied the code from.
The same operation must occur in the entity_translation_upgrade_do during an entity_translation_upgrade
Somewhere between beta5 and the current 1.x dev , this became an issue, or perhaps I didn't notice it before.
But yes, the patch is needed, would prefer to perform refactoring in a new ticket, I maintain my call for RTBC, feel free to make a new change to the logic as long as it works , but this patch works as is, and is following the design pattern set up by the developers of entity_translation.
Comment #15
joseph.olstadComment #16
joseph.olstadas in, ? what? entity_translation? lol
the patch >is< consistent with entity_translation, as described.
Comment #17
joseph.olstadWant a side order of chicken and some fries with that?
Comment #18
stefanos.petrakis@gmail.comWith inconsistent I meant that reading that code in isolation, leads to the conclusion that if
$handler->translations->original
is not set, then it is safe to overwrite the$handler->translations->data
property by callinginitTranslations()
. That is a leap of faith. Any useful feedback on that specific point?Even if that code came from the current code base, it doesn't mean that there is no room for reviews and/or improvement.
And code duplication should be avoided.
About testing: increasing the test coverage is a must on the way to a stable release (#1624830: Plan for Entity Translation 7.x-1.0 release).
The current patch passes testing because there is no test case for the problem we are dealing with in this issue.
We are trying to reproduce the error which means we are half-way done with the testing conceptually, I already suggested a testing scenario.
Any possibility on helping with adding tests?
Comment #19
joseph.olstadOk, I protest, but if you insist.
Comment #20
joseph.olstadComment #22
joseph.olstadhere's another one, not sure why #19 failed , been a long day.
Comment #23
joseph.olstadComment #24
joseph.olstadComment #27
joseph.olstadthis unrelated code sniffer patch was autogenerated , interesting, nice job drupal.org , if you're going to complain, at least be helpful about it.
https://dispatcher.drupalci.org/job/drupal_d7/31890/artifact/jenkins-dru...
Comment #28
joseph.olstadtabarnak de câlissse
Comment #29
joseph.olstadComment #32
joseph.olstadlooks like handler object has a problem with pointers or pass by reference?
who cares?
ALRIGHT, it was a nice though, ok, back to PATCH 5 yet????????????????????????
Comment #33
joseph.olstadok, back to patch 5
Comment #35
joseph.olstadpatch 30 failed too.
stefanos.petrakis
can we just go with patch 5 ?
or can you please explain to me why patch 30 isn't working?
Comment #36
stefanos.petrakis@gmail.comHere is a rewrite with tests.
The tests (entity_translation-tests-2899658-36.patch) should fail when run on their own, because of the reported issue.
The fix on its own (entity_translation-fix_for_empty_translations-2899658-36.patch) is here for reference and follows the idea of simplicity/readability (for the next time someone has to look at that piece of code).
The idea from @joseph.olstad about wrapping this inside a function is good for code reuse, but I don't want to refactor other files (entity_translation.admin.inc) without having some proof that we won't break sth. Optimally this should move into a new task.
The complete tests+fix patch (entity_translation-upgrade_fix_with_tests_added-2899658-36.patch) is also available and should be used to resolve this issue.
Let's see what the CI thinks. And a big thanks to @joseph.olstad for the amazing efforts here.
Comment #39
joseph.olstadNice work Stefanos, the tests pass except an unrelated strict warning
Comment #40
joseph.olstadNice, the tests are requeued after the unrelated issue was fixed.
expecting a pass.
Comment #41
joseph.olstadOk, so the tests without the fix and with the fix prove that the fix is needed and is working.
without the fix, this will fail
WITH the fix, it passes.
Comment #42
joseph.olstadRTBC this one:
https://www.drupal.org/files/issues/entity_translation-upgrade_fix_with_...
upgrade fix with tests.
Thanks Stefanos for awesome tests!
Comment #43
joseph.olstad71 passes
Comment #45
stefanos.petrakis@gmail.comCommitted!
Comment #46
joseph.olstadThanks very much!
Comment #47
joseph.olstadbtw, I created a freebie patch for you based on the d.o code sniffer results from one of my failed patches (above).
see the patch here:
#2900094: Run a coder review on the ET codebase
Comment #48
joseph.olstadCredit should also go to dsutter and gdaw, dsutter for finding the needle in the haystack, and gdaw for his thorough quality assurance.
Thanks everyone!