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

Refactor get_title_cache to be straightforward #6829

Merged

Conversation

jonathan-s
Copy link
Contributor

Prior to this patch if the cache is partially filled it would have used a fallback rather than trying to fill the cache with the correct pagecontent.

  • I have opened this pull request against release/4.0.x
  • I have updated the CHANGELOG.rst
  • I have added or modified the tests when changing logic

As well as correct during cache miss
Copy link
Contributor

@Aiky30 Aiky30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was actually done on Friday, the browser had cached it luckily. @jonathan-s

return lang

if not language:
language = get_language()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_fallback_language would have been called here if fallback is true and would have run before the force_reload, this could have unforeseen side affects. I can see that this condition is ran below with the use_fallbacks option, I'm not sure how that could affect being run later after the force reload.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, you'll see the effects of this in the test that I provided. If you ran the test prior to this patch the test would fail. With this patch, the test passes.


if fallback and not self.title_cache.get(language):
# language can be in the cache but might be an EmptyPageContent instance
def get_fallback_language(page, language):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, maybe as this is private it should be called: _get_fallback_language

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this created to attack it from versioning ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this method was made to reduce clutter. The same code was repeated twice. Also having a name get_fallback_language makes the code easier to parse than the block of code that does not have a name.


def test_get_title_obj(self):
"""
Cache partially populated, if no hit it should try to populate it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a test cache test file, this should live in there. I thought that we had a test_title file, seems that we don't.

@jonathan-s
Copy link
Contributor Author

🎉 🎉

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.

None yet

2 participants