Updated code related to cache management in CMS core and modules.

This commit is contained in:
2015-11-02 10:50:05 +01:00
parent e40a7969fa
commit 5624892ebc
5 changed files with 49 additions and 42 deletions

View File

@@ -99,6 +99,8 @@ feature -- Security
Result.force ("admin roles") Result.force ("admin roles")
Result.force ("admin modules") Result.force ("admin modules")
Result.force ("install modules") Result.force ("install modules")
Result.force ("admin core caches")
Result.force ("clear blocks cache")
end end
feature -- Hooks feature -- Hooks
@@ -128,14 +130,10 @@ feature -- Hooks
lnk.set_permission_arguments (<<"manage " + {CMS_ADMIN_MODULE}.name>>) lnk.set_permission_arguments (<<"manage " + {CMS_ADMIN_MODULE}.name>>)
a_menu_system.management_menu.extend (lnk) a_menu_system.management_menu.extend (lnk)
end end
if -- Per module cache permission!
a_response.has_permission ("admin cache") -- Note: admin user has all permissions enabled by default.
then
create lnk.make ("Cache", "admin/cache") create lnk.make ("Cache", "admin/cache")
lnk.set_permission_arguments (<<"admin cache">>)
a_menu_system.management_menu.extend (lnk) a_menu_system.management_menu.extend (lnk)
end end
end
note note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"

View File

@@ -42,14 +42,10 @@ feature -- Execution
f: CMS_FORM f: CMS_FORM
do do
create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api) create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api)
if l_response.has_permission ("admin cache") then
f := clear_cache_web_form (l_response) f := clear_cache_web_form (l_response)
create s.make_empty create s.make_empty
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s) f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
l_response.set_main_content (s) l_response.set_main_content (s)
else
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
end
l_response.execute l_response.execute
end end
@@ -60,7 +56,6 @@ feature -- Execution
f: CMS_FORM f: CMS_FORM
do do
create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api) create {GENERIC_VIEW_CMS_RESPONSE} l_response.make (req, res, api)
if l_response.has_permission ("admin cache") then
f := clear_cache_web_form (l_response) f := clear_cache_web_form (l_response)
f.process (l_response) f.process (l_response)
if if
@@ -69,7 +64,7 @@ feature -- Execution
then then
if attached fd.string_item ("op") as l_op and then l_op.same_string (text_clear_all_caches) then if attached fd.string_item ("op") as l_op and then l_op.same_string (text_clear_all_caches) then
l_response.hooks.invoke_clear_cache (Void, l_response) l_response.hooks.invoke_clear_cache (Void, l_response)
l_response.add_notice_message ("Cache cleared!") l_response.add_notice_message ("Caches cleared (if allowed)!")
else else
fd.report_error ("Invalid form data!") fd.report_error ("Invalid form data!")
end end
@@ -77,9 +72,6 @@ feature -- Execution
create s.make_empty create s.make_empty
f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s) f.append_to_html (create {CMS_TO_WSF_THEME}.make (l_response, l_response.theme), s)
l_response.set_main_content (s) l_response.set_main_content (s)
else
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
end
l_response.execute l_response.execute
end end

View File

@@ -46,9 +46,13 @@ feature -- Access
-- List of permission ids, used by this module, and declared. -- List of permission ids, used by this module, and declared.
do do
Result := Precursor Result := Precursor
Result.force ("manage feed aggregator") Result.force (permission__manage_feed_aggregator)
Result.force (permission__clear_feed_cache)
end end
permission__manage_feed_aggregator: STRING = "manage feed aggregator"
permission__clear_feed_cache: STRING = "clear feed cache"
feature {CMS_API} -- Module Initialization feature {CMS_API} -- Module Initialization
initialize (api: CMS_API) initialize (api: CMS_API)
@@ -194,6 +198,7 @@ feature -- Hook
p: PATH p: PATH
dir: DIRECTORY dir: DIRECTORY
do do
if a_response.has_permissions (<<permission__clear_feed_cache, permission__manage_feed_aggregator>>) then
if a_cache_id_list = Void then if a_cache_id_list = Void then
-- Clear all cache. -- Clear all cache.
p := a_response.api.files_location.extended (".cache").extended (name) p := a_response.api.files_location.extended (".cache").extended (name)
@@ -203,6 +208,7 @@ feature -- Hook
end end
end end
end end
end
block_list: ITERABLE [like {CMS_BLOCK}.name] block_list: ITERABLE [like {CMS_BLOCK}.name]
-- List of block names, managed by current object. -- List of block names, managed by current object.
@@ -341,7 +347,7 @@ feature -- Hook
-- for related response `a_response'. -- for related response `a_response'.
do do
a_menu_system.navigation_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds", "feed_aggregation/")) a_menu_system.navigation_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds", "feed_aggregation/"))
if a_response.has_permission ("manage feed aggregator") then if a_response.has_permission (permission__manage_feed_aggregator) then
a_menu_system.management_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds (admin)", "admin/feed_aggregator/")) a_menu_system.management_menu.extend (create {CMS_LOCAL_LINK}.make ("Feeds (admin)", "admin/feed_aggregator/"))
end end
end end

View File

@@ -219,7 +219,7 @@ feature -- Hook: cache
end end
end end
a_response.clear_block_caches (a_cache_id_list) a_response.clear_cache (a_cache_id_list)
end end
end end

View File

@@ -997,6 +997,17 @@ feature -- Element Change
status_code_set: status_code = a_status status_code_set: status_code = a_status
end end
feature -- Cache managment
clear_cache (a_cache_id_list: detachable ITERABLE [READABLE_STRING_GENERAL])
-- Clear caches identified by `a_cache_id_list',
-- or clear all caches if `a_cache_id_list' is Void.
do
if has_permissions (<<"clear blocks cache", "admin core caches">>) then
clear_block_caches (a_cache_id_list)
end
end
feature -- Generation feature -- Generation
prepare (page: CMS_HTML_PAGE) prepare (page: CMS_HTML_PAGE)