You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered, that the error handling of DOM objects in PHP is pretty stupid:
If eg. during the buildSourceForXlfFile method an error occurs, the resource pointer of the DOMDocument gets an empty body without any Exception to be thrown.
It's even worse: as prepareDomDocument stores the resourcePointer to the DOMDocument in a local static variable, the LanguageFileService continues working on an empty body and just appends the new labels into it and writes the file afterwards. So the old labels are lost.
So one possible solution is to always re-read the file (bad for I/O) and do some integrity checks, like cloning the DOMDocument and comparing the count of the trans-unit nodes before and after insertion:
I think re-reading the file after writing each label (possibly combined with integrity checks to confirm it actually was written correctly and restoring it if it wasn't) would be the way to go. Don't worry too much about I/O performance on this one - FLLL is explicitly a development-only extension with big warnings attached to using it in production ;)
I discovered, that the error handling of DOM objects in PHP is pretty stupid:
If eg. during the
buildSourceForXlfFile
method an error occurs, the resource pointer of theDOMDocument
gets an empty body without any Exception to be thrown.It's even worse: as
prepareDomDocument
stores the resourcePointer to theDOMDocument
in a local static variable, theLanguageFileService
continues working on an empty body and just appends the new labels into it and writes the file afterwards. So the old labels are lost.So one possible solution is to always re-read the file (bad for I/O) and do some integrity checks, like cloning the DOMDocument and comparing the count of the trans-unit nodes before and after insertion:
But I'm not happy with that solution as it looks pretty hacky. Any suggestions on that?
The text was updated successfully, but these errors were encountered: