prevent nested templatePlugin from overwriting parent instance #19
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.
@Seldaek I know dwoo1 is end-of-life, but dwoo2 isn't suitable for me yet. I expect you won't want to merge any more pull requests but if you could comment on this a bit it would be very helpful as I wasn't able to discern the original intention behind appending templatePlugin function names with _$uuid
Scenario
test.tpl:
test.sub1.tpl:
test.sub2.tpl:
Problem
The above example fails on test.tpl's call to
{sub1}
withFatal error: Call to undefined function Dwoo_Plugin_sub1_535188f29fcdb()
because{load_templates test.sub2.tpl}
copies an instance of{sub1}
with a different UUID from the cloned compiler back to the original compiler, causing the function written to the compiled template to use the UUID generated within test.sub2.tplSolution
The best solution I could find was to remove the _$uuid suffix from generated templatePlugin functions and prevent Compiler->addTemplatePlugin from overwriting an existing templatePlugin entry with one with a new UUID. Indexing template plugins by only their name in the templatePlugins array implies the names should be globally unique, so I couldn't make sense of why the function name needed to have the UUID appended. I kept the UUID logic in place for generating the scope though.
Unanswered Question