Skip to content

Commit

Permalink
fix: clear routing cache on homepage change
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Mar 13, 2024
1 parent d9d2943 commit d758af5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions frappe/core/doctype/role/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"timeline",
"dashboard",
)
from frappe.website.router import clear_routing_cache

STANDARD_ROLES = ("Administrator", "System Manager", "Script Manager", "All", "Guest")

Expand Down Expand Up @@ -69,6 +70,9 @@ def validate_homepage(self):
if frappe.request and self.home_page:
validate_path(self.home_page)

if self.has_value_changed("home_page"):
clear_routing_cache()

def set_desk_properties(self):
# set if desk_access is not allowed, unset all desk properties
if self.name == "Guest":
Expand Down
2 changes: 1 addition & 1 deletion frappe/tests/test_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def test_user_cache_clear(self):
frappe.clear_cache(user=user1)

# Check that the keys for user1 are gone
for key in user_cache_keys:
for key in set(user_cache_keys) - {"home_page"}:
self.assertFalse(frappe.cache.hexists(key, user1))
self.assertTrue(frappe.cache.hexists(key, user2))

Expand Down
1 change: 1 addition & 0 deletions frappe/website/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,4 @@ def clear_routing_cache():
get_dynamic_web_pages.clear_cache()
get_published_web_forms.clear_cache()
get_public_pages_from_doctypes.clear_cache()
frappe.cache.delete_value("home_page")

0 comments on commit d758af5

Please sign in to comment.