Make phpodt work in a parallel environment#36
Open
sboden wants to merge 29 commits intocybermonde:masterfrom
Open
Make phpodt work in a parallel environment#36sboden wants to merge 29 commits intocybermonde:masterfrom
sboden wants to merge 29 commits intocybermonde:masterfrom
Conversation
added 8 commits
December 6, 2022 21:17
Owner
|
Thanks for keeping this project alive, sorry I don't have time to improve it anymore. |
Fix - Call to htmlspecialchars() is is null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First up: the composer changes can be reverted of course.
cybermonde/phpodt overwrites data in a parallel execution setting, and this pull request fixes that.
We were using phpodt as a templating engine to created ODT letters to be converted by jodconverter to PDF. It's part of a Drupal application that sends about 50.000 letters per day. Generating a letter from beginning to end took 5 seconds, so we executed the creation of letters in parallel (about 15 threads creating them). What we noticed after a couple of weeks is that some people received the letter of another person (about 1 in 15.000).
We investigated and came to the conclusion that cybermonde/phpodt is not suited to run in parallel, in particular when you use PclZipProxy: both phpodt and pcl.zip.lib make some wrong assumptions about "unique" output locations. We mitigated the problem by extracting the text from the final pdf, comparing the text to the document number we were printing for, and ignoring/retrying the output when they differed.
The detail root cause: phpodt used uniq() to get a unique temp filename. Unfortunately uniq() is only a kind of hex representation of the current time so sometimes it returns the same value in different threads causing data overwrites. The pcl.zip.lib library included does the same in a couple of places.
If you only have 1 thread creating letters than the current cybermonde/phpodt should be fine.
This pull request are all the changes I made to make phpodt able to run in parallel without problems. I did not change the existing interfaces. The sboden/phpodt (2.2.1) of this pull request code has been running for about a week in production, so after +-300,000 letters no overwritten printouts were detected anymore.
wfr,
Sven