8000 fix: Language tabs didn't show existing content due to caching issue by filipweidemann · Pull Request #8046 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: Language tabs didn't show existing content due to caching issue #8046

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

Merged
merged 5 commits into from
Oct 29, 2024

Conversation

filipweidemann
Copy link
Contributor

Description

This PR resolves issue #8044 by not setting the admin_content_cache when calling get_object. Doing so resulted in partial caches being present for only the currently selected language, meaning that any use of the cache would yield an EmptyPageContent object instead of the actual content.

This breaks the language tabs inside the page edit form. Not setting the cache partially now triggers the set_admin_content_cache method and resolves this issue.

Related resources

#8044

Checklist

  • I have opened this pull request against develop-4
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined the channel #pr-reviews on our Discord Server to find a “pr review buddy” who is going to review my pull request.

…g create forms inside the admin language tabs
if obj:
obj.page.admin_content_cache[obj.language] = obj
return obj
return super().get_object(request, object_id, from_field)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can delete the whole method; all it does is calling super().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hehe, absolutely. Hadn't had my coffee before removing the lines. Going to change it real quick...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fsbraun done :)

Copy link
Member
@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

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

I've added a second change to improve the UX on the language tabs (see here for the reason: #8044 (comment)

Also, I see no performance issue.

@fsbraun fsbraun changed the title Fix partial admin_content_cache in get_object wrapper (#8044) fix: Language tabs didn't show existing content due to caching issue Oct 29, 2024
@filipweidemann
Copy link
Contributor Author
filipweidemann commented Oct 29, 2024

Also, I see no performance issue.

@fsbraun me neither. I think this is fine, your change also improves this quite a bit. Personally I am happy with this, it should be all we need to fix the issue for all CMS users!

Edit: also very good PR title, way better than mine. Thanks ^^

@fsbraun
Copy link
Member
fsbraun commented Oct 29, 2024

@filipweidemann This looks good to me. Do you have an idea on how we can add a test that ensures this will not break again in the future?

@filipweidemann
Copy link
Contributor Author

@filipweidemann This looks good to me. Do you have an idea on how we can add a test that ensures this will not break again in the future?

Currently I don't. But I can have another look later.
But since this is a rather serious bug (in my opinion) I'd say that we should maybe merge this without a test being present right now?

I will then create another issue and assign myself to add the missing test cases.

How does that sound? :)

@fsbraun
Copy link
Member
fsbraun commented Oct 29, 2024

@filipweidemann I added a class called AdminCacheDict that raises an error if you try setting individual values. I think we should be fine with this!

Copy link
Member
@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

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

@filipweidemann Thank you so much for the excellent deep dive!

@fsbraun
Copy link
Member
fsbraun commented Oct 29, 2024

Fixes #8044

@fsbraun fsbraun merged commit db0a0c7 into django-cms:develop-4 Oct 29, 2024
51 checks passed
@filipweidemann
Copy link
Contributor Author

@filipweidemann Thank you so much for the excellent deep dive!

Sure thing, thanks for the fast merge. I actually just read your idea about the "immutable" AdminCacheDict implementation and wanted to proactively implement this, but then saw that you already did.

Great stuff :)

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.

2 participants
0