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
When XLIFF is imported, there's a certain validation phase.
If you see at method validateImport(), there's tons of abort conditions that clearly test specific abort cases, but don't provide a meaningful message.
This leads to aborts with just messages like "Failed to validate file, import aborted."
Proposed resolution
For every condition to abort, add a specific error message.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#34 | xliff_validation_fail-2278093-34-interdiff.txt | 610 bytes | sasanikolic |
#34 | xliff_validation_fail-2278093-34.patch | 7.11 KB | sasanikolic |
#30 | xliff_validation_fail-2278093-30-interdiff.txt | 610 bytes | sasanikolic |
#30 | xliff_validation_fail-2278093-30.patch | 45.43 KB | sasanikolic |
#28 | xliff_validation_fail-2278093-28.patch | 7.71 KB | sasanikolic |
Comments
Comment #1
blueminds CreditAttribution: blueminds commentedMessages added.
Comment #2
blueminds CreditAttribution: blueminds commentedJust realized that the message type was not set.
Comment #3
miro_dietikerI do like to see the (job id, language) values in the message.
Comment #4
blueminds CreditAttribution: blueminds commentedyup
Comment #5
miro_dietikerOops, found some UI issue.
Comment #6
blueminds CreditAttribution: blueminds commentedThat is this one.
Comment #7
miro_dietikerProviding new patch with way improved error handling. Untested...
Added new optional $job param to validateImport and match the Job ID. Fixing also #2278093: XLIFF validation fail without more information
Will test in production and apply if it works later.
Comment #9
blueminds CreditAttribution: blueminds commentedThis condition made the inner checks skip if the job was provided. Being able to validate we should make the job argument compulsory so the tjid checks can be carried out.
Comment #10
blueminds CreditAttribution: blueminds commentedthe patch is the same as interdiff... sry
Comment #12
miro_dietikerNo, making it mandatory changes the interface and this is not correct - see drush usage that doesn't provide it!
Providing improved version with your test fixes. Thank you.
Comment #14
miro_dietikerFixing again ;-)
Comment #15
miro_dietikerAww i need to write more patches to get back again into the flow. ;-)
Comment #16
BerdirI'm not sure what this and the related changes have to do with this issue?
The idea of this process was to support a global import translation form that can find out the job it applies to automatically and also support uploading multiple translations at once and so on.
Or the existing drush integration, which also gets the job from the file.
Sure this could be split into a separate method but finding out the job it applies to is validation too (checking if it is actually a xliff file that we generated with the necessary metadata to identify the job).
Comment #17
BerdirWe discussed this a bit.
The main problem is that the @todo and the added argument/job-is-the-same validation go in a different direction. If we would implement the @todo and separate the "get the job" part in a separate method, then keeping that part of the validation inside the validate method would no longer sense and we'd have to change it again.
Discussed this with Miro, we decided to keep the @todo (a reference to an issue would be nice there, can be a dummy) and instead move the "job is the same" part of the validation into the form validate callback that invokes the validate method. That' more future proof and makes this part of an internal implementation instead of a public API.
Comment #18
miro_dietikerAs discussed, added new @todo about addMessage and unsafe Context.
Comment #19
miro_dietikerOoops, wrong patch :-!
Comment #21
miro_dietikerNiiiice, retry fixing test.
Comment #22
miro_dietikerYay! Committed!
Followup is #2278997: Create file import processor to moderate job
Comment #23
blueminds CreditAttribution: blueminds commentedIf committed shouldn't the status be updated as well?
Comment #24
miro_dietikerThx, i thought i did.
Comment #26
miro_dietikerUh, needs port to 8.x
Comment #27
miro_dietikerComment #28
sasanikolic CreditAttribution: sasanikolic commentedPorted to 8.x with a simple test.
Comment #29
Berdirmethods in an interface area always public, it's possible that we did this in the 7.x patch, but it's not necessary.
Comment #30
sasanikolic CreditAttribution: sasanikolic commentedOk, removed the public definition of the method validateImport.
Comment #32
BerdirArg, accidently committed this. Patch has not been rerolled properly and is reverting a lot of stuff.
Comment #34
sasanikolic CreditAttribution: sasanikolic commentedSorry about that. Should be fine now...
Comment #35
BerdirBetter :)