Skip to content

Conversation

@tim-schilling
Copy link
Member

Move the stack trace loop into a utility method. Check for calls to get_template_context.

I wasn't sure about the logic to check the current file. I had it done programmatically, but that was ugly and probably more confusing than just checking the string value of the name.

Closes #598

@aaugustin
Copy link
Contributor

I'm not really sure of how all this works -- which means you can merge it if it works for you :-)

However, if that isn't too hard, it would be nice to have a test for the recursion detection.

@tim-schilling
Copy link
Member Author

So I was able to reproduce it manually, but I can't seem to reproduce it with Django's test runner. I believe it has something to do with the test runner forcing DEBUG=False, and using override_settings to set it back to True doesn't have the same effect as simply running it as DEBUG=True.

Move the get_template_info stacktrace loop into a utility method.
Check for calls to get_template_context to prevent the infinite recursion.

The bug requires TEMPLATE_DEBUG=True, for the template to extend
another template and SQL to be run in the template loader.
With this configuration the SQL Panel would identify the SQL query
while loading the template, then try to load the template again which
would create a new SQL query ending in an infinite recursion.

Skip the infinite recursion regression test for Django < 1.5

The test is being skipped because Django 1.4 loads the TEMPLATE_LOADERS
before override_settings can modify it. This means that the SQL query
isn't run when loading the template which causes the test to fail.

The other solution would have been to add a conditional setting, but that
could introduce unexpected results in future tests. Skipping this test is
the safer, more conservative approach.

Closes #598.
@tim-schilling tim-schilling merged commit f7fc3d9 into django-commons:master Oct 25, 2014
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 this pull request may close these issues.

Infinite recursion for template loaders that query the database

2 participants