Invalidate cached urls for all frontend locales #1479

Merged
merged 1 commit into from Mar 20, 2012
Jump to file or symbol
Failed to load files and symbols.
+10 −8
Diff settings

Always

Just for now

@@ -294,16 +294,16 @@ def nested_path
Rails.cache.fetch(path_cache_key) { ['', nested_url].join('/') }
end
- def path_cache_key
- [cache_key, 'nested_path'].join('#')
+ def path_cache_key(locale=::I18n.locale)
+ [cache_key(locale), 'nested_path'].join('#')
end
- def url_cache_key
- [cache_key, 'nested_url'].join('#')
+ def url_cache_key(locale=::I18n.locale)
+ [cache_key(locale), 'nested_url'].join('#')
end
- def cache_key
- [Refinery::Core.base_cache_key, 'page', ::I18n.locale, id].compact.join('/')
+ def cache_key(locale)

This comment has been minimized.

Show comment Hide comment
@parndt

parndt Mar 20, 2012

Member

All the others have default values of I18n.locale but not this one?

@parndt

parndt Mar 20, 2012

Member

All the others have default values of I18n.locale but not this one?

This comment has been minimized.

Show comment Hide comment
@vita

vita Mar 20, 2012

Contributor

Because this method is calling only in path_cache_key and url_cache_key methods and there is locale already set to default value I18n.locale.

@vita

vita Mar 20, 2012

Contributor

Because this method is calling only in path_cache_key and url_cache_key methods and there is locale already set to default value I18n.locale.

+ [Refinery::Core.base_cache_key, 'page', locale, id].compact.join('/')
end
# Returns true if this page is "published"
@@ -415,8 +415,10 @@ def invalidate_cached_urls
return true unless Refinery::Pages.marketable_urls
[self, children].flatten.each do |page|
- Rails.cache.delete(page.url_cache_key)
- Rails.cache.delete(page.path_cache_key)
+ ::Refinery::I18n.frontend_locales.each do |locale|
+ Rails.cache.delete(page.url_cache_key(locale))
+ Rails.cache.delete(page.path_cache_key(locale))
+ end
end
end
alias_method :invalidate_child_cached_url, :invalidate_cached_urls