Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
From the code it is unclear if things break fatal, or if TMGMT still works fine if we have jobs / items assigned to a translator... and then delete the translator.
All cases, from new jobs, submitted, needs review and closed need to be tested.
Proposed resolution
If it breaks, fix.
I guess a test should cover these cases.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#31 | verify_stability_with-2538360-31-interdiff.txt | 664 bytes | sasanikolic |
#31 | verify_stability_with-2538360-31.patch | 12.78 KB | sasanikolic |
#29 | verify_stability_with-2538360-29-interdiff.txt | 516 bytes | sasanikolic |
#29 | verify_stability_with-2538360-29.patch | 12.77 KB | sasanikolic |
#26 | verify_stability_with-2538360-26-interdiff.txt | 516 bytes | sasanikolic |
Comments
Comment #1
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedComment #2
miro_dietikerAnother try. ;-)
Comment #3
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedAs I can see, we have a check that makes sure that translators can't be removed if there are active jobs using it.
I will extend the tests.
Comment #4
miro_dietikerYeah, that test seems pretty fine...
Then let's alter JobInterface::getTranslator() to return the translator entity or an Exception in case it was unsuccessful.
It should provide a hasTranslator that checks if a Translator is selected and the plugin is around...
There are other getTranslator methods that need similar fixing.
If a caller wants to deal with the situation, it needs to add a catch, but it seems in the current implementation, that's not needed..
Comment #5
miro_dietikerThis issue should consider #2504639: Fatal error when clicking 'in progress' without a translator once in.
Comment #6
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedUploading patch with current progress. Added the functions hasTranslator and hasPlugin. There will probably be some test fails.
Also, removed the condition that is checking the active job attached to the translator. So now, we can't delete a translator if it has any job connected with it. In a followup, we should create some kind of automatization that deletes all connections between the translator and the (active) job.
Comment #8
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedFixed the test fails...
Also, changed TranslatorTest for the error message, because now we can't delete translators that are connected with a job.
Comment #9
miro_dietikerYes, this makes things much cleaner.
You might want to check separately for target_id / hasPlugin and provide an explanation on why you can't get the translator.
Doesn't need to change. 2 lines less with a fallback return FALSE.
I wonder if we should drop this method at all now. Let's discuss in a followup.
From coding standard:
"All caps are used in comments only when referencing constants, for example TRUE."
So use all caps.
bool
That's quite some change. I think we should add some test coverage to proof the new logic.
In the test that checks if the delete fails when items are there, please set the job also to a different state (such as STATE_FINISHED) and retest deletion error message.
Comment #10
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedCreated a followup for the discussion about dropping
getTranslatorPlugin()
.Comment #11
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedAdded the fixes.
About the last comment about the test, we have a check for the STATE_FINISHED. Should we also test all/some other states?
Comment #12
BerdirI think we can improve those messages a bit. What about...
The job has no translator assigned.
and
The translator assigned to this job is missing the plugin.
This method might be easier to follow have the if/elseif first and actually return it at the end.
The check that you are doing is already returning a boolean, so you can write that as return $this->translator->target_id && ...
Also, to be sure, you want to check ->entity, since it is possible that it is referencing a non-existing translator, so an ID would be set but couldn't be loaded.
that description is very helpful I would never have guessed that without that ;)
Instead, decribe when an exception is thrown. Also, should have full namespace.
This is an implementation of a base class/interface, so just @inheritdoc.
This logic doesn't make sense anymore, it will never go into the Missing Translator case anymore. That needs to become the else case or you need to remove the if again and use hasTranslator() on he first check.
Hm. AFAIK it was a feature that you can delete a translator that is only used on completed jobs, why is this changed?
Comment #13
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedOk fixed the issues above, reverted and extended the test.
Also, after talking with @berdir, reverted back the condition for deleting translators only when the job is not in active state as it was at the beginning.
Comment #15
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedUhm, uploaded the wrong patch.
Comment #16
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedThis other method also needs more explanation about when it throws the exception.
The rest looks fine for me.
Comment #17
mbovan CreditAttribution: mbovan at MD Systems GmbH commented2 extra spaces needed for doc block.
Else block can be removed and only return false after if condition.
Comment is longer than 80 characters.
Berdir's comment (#12/3).
Comment #18
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedFixed other points above.
Comment #20
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedAdded
hasTranslator
to theJobItemInterface
and changed JobItemForm.#2504639: Fatal error when clicking 'in progress' without a translator broke the tests. This patch should fix it.
Comment #21
Berdirleft-over change, should be reverted too.
Looks good to me, we could hold on and try to find more possibly broken cases. One that we should possibly try is deleting a translator of a completed job and then viewing the job and job items again. Can you try that and extend the existing test for that?
But other than that, I think we should go ahead and get this in asap.
Comment #22
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedHere is the extended test with the fixes.
Comment #24
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedStill there?
Comment #25
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedJob messages config file changes for the test fails.
Comment #26
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedNitpick, removed the "y" from any (#24).
Comment #29
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedRebased.
Comment #30
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedRevert the change here, this isn't translatable anymore.
After that I'll give my blessing :P.
Comment #31
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedReverted. :)
Comment #32
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedLooks fine!
Comment #33
BerdirI think so too. Committed.