-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Conversation
…g create forms inside the admin language tabs
cms/admin/pageadmin.py
Outdated
if obj: | ||
obj.page.admin_content_cache[obj.language] = obj | ||
return obj | ||
return super().get_object(request, object_id, from_field) |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fsbraun done :)
…if they are unpublished or archived
There was a problem hiding this 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 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 ^^ |
@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. I will then create another issue and assign myself to add the missing test cases. How does that sound? :) |
@filipweidemann I added a class called |
There was a problem hiding this 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!
Fixes #8044 |
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 :) |
Description
This PR resolves issue #8044 by not setting the
admin_content_cache
when callingget_object
. Doing so resulted in partial caches being present for only the currently selected language, meaning that any use of the cache would yield anEmptyPageContent
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
develop-4