-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use XML API instead of string replacement in cloneBlock and replaceBlock #1354
base: master
Are you sure you want to change the base?
Use XML API instead of string replacement in cloneBlock and replaceBlock #1354
Conversation
Implements the fonction gave by brad-jones on the issue : PHPOffice#341 (comment)
aca145c
to
5f5f9d0
Compare
5f5f9d0
to
232ab1f
Compare
3e8ea9a
to
5574e21
Compare
Would be great if someone could take a first look before I'm making all the tests pass 😃 |
5574e21
to
b451948
Compare
I think it is indeed much safer to treat xml as xml instead of trying to parse it with regular expressions (although the memory consumption is probably not the same?)! The only problem with this refactoring is that it will probably make most of the currently open pull requests (add image, delete row, ...) very hard to merge. Any refactoring of this magnitude will definitely need complete test coverage to be sure we do not introduce regressions. I'm planning on having version 0.16 dedicated to the TemplateProcessor. |
as a first remark, wouldn't it be better to parse the tempDocumentMainPart to XML only once. |
Thanks for your feedback @troosan!
Definitely - I took this shortcut for now just to avoid having to refactor even more 😄 But if we agree that this is the way to go forward, it's definitely worth it to make sure the parsing is only done once.
You're right - but I guess in the long run it makes most sense to make sure that we're building on a solid foundation. |
First of all thank you so much for your work. I'm very impatient to see your PR merged, because this might solve some of my problems in using phpword. What is the current state of that PR ? Can I do something to make it go further ? |
Hi @nguyenk! Unfortunately, I don't think I'll find the time to finish this PR in the near future. While current state seems to work, it still needs to be optimized (parse to XML only once) and it lacks proper testing. It would be awesome if you could try to continue work on this - let me know if there is anything I could help with! |
6a60ae7
to
2d9f999
Compare
Description
This started as a simple update of #541, but turned into a rewrite of the clone/replace functionality based on
DOMDocument
APIs.I'd be glad to get some feedback on this before I start making the tests pass.
Fixes #316, #341, #867
Checklist:
composer run-script check --timeout=0
and no errors were reported