Skip to content
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

ckan_extends cache depends on template paths #5131

Closed
wardi opened this issue Dec 19, 2019 · 0 comments · Fixed by #5172
Closed

ckan_extends cache depends on template paths #5131

wardi opened this issue Dec 19, 2019 · 0 comments · Fixed by #5172
Assignees

Comments

@wardi
Copy link
Contributor

wardi commented Dec 19, 2019

CKAN Version if known (or site URL)

all versions

Please describe the expected behaviour

{% ckan_extends %} should extend templates from the next path in the template paths list

Please describe the actual behaviour

{% ckan_extends %} emits a node with a numeric index into the template path list, which is cached with the rest of the compiled template. If the plugins enabled or template paths change after caching the template {% ckan_extends %} will extend from the wrong position in the template paths list. This behavior could lead to an infinite loop, a skipped intermediate template or a TemplateNotFound error (even for templates present in ckan itself)

What steps can be taken to reproduce the issue?

  • create a template using {% ckan_extends %}, enable the jinja2_cache_dir setting
  • visit a page that causes the template to be cached
  • modify the plugins list to add/remove plugins with template directories or add/remove modify the template_extra_paths setting
  • visit the page again for unexpected behavior

This is where the numeric index is added to the extends node, which is cached:

magic_filename = '*' + str(index) + '*' + filename

This is where the cached numeric index is used on the current template path list:

if template.startswith('*'):
parts = template.split('*')
template = parts[2]
searchpaths = self.searchpath[int(parts[1]) + 1:]

I suggest we switch this to emit the current template directory instead of a number so that we won't get this unexpected behavior.

wardi added a commit that referenced this issue Jan 29, 2020
…th-template-directory

[#5131] index template with template path instead of numeric index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant