tickets: 6516
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6516 | 2008-01-30 23:52:04 | 2011-06-14 15:07:53 | 2022-03-06 03:37:20.615353 | Unreviewed | closed | Template system | Bug | Normal | dev | fixed | Template extends bug when passing a template variable to extends tag | This is loosely related to #5124, at least the problems lie in the same code where extends resolution occurs during rendering of the !ExtendsNode. Extended templates are fetched at the time that a child template is rendered. This is done to defer fetching the extended template in the case where a variable is used to specify the template, as a context must be available. This occurs in all cases, even when a hard coded string is passed, I assume to avoid having multiple !ExtendsNode types in similar fashion to the !IncludeNode types. When an extended template is fetched, it is modified in two ways. First, if the extended template also extends and there is a block in the child template that does not exist in the parent, that block is appended to the parents !ExtendsNode nodelist. Second, when the block does exist in the parent, it is inserted into the parent template and block in the parent template is attached to the parent attribute of the inserted block to support block.super. In the two cases where a template name is passed, either as a variable or hard coded, this does not cause a problem, as the template is fetched from source and discarded after rendering. However in the case where an instantiated template is passed in, the passed in template is modified. Rendering a template (or it's child) should make no changes to a template that will appear if it is rendered again. I've included a file that demonstrates the case where the child block is inserted into the parent template with a link to it's super block. The other case should not be too hard to verify with a three layer heirarchy. I've also included a diff that '''does not''' fix the problem, but cleans up the code a bit and helps to clarify what is going on. | nobody | AmanKow | extends template overwrite | 0 | 0 | 0 | 0 | 0 | 0 |