Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Invalidate cached urls for all frontend locales #1479

Merged
merged 1 commit into from

2 participants

@vita

No description provided.

@parndt parndt commented on the diff
pages/app/models/refinery/page.rb
((14 lines not shown))
end
- def cache_key
- [Refinery::Core.base_cache_key, 'page', ::I18n.locale, id].compact.join('/')
+ def cache_key(locale)
@parndt Owner
parndt added a note

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

@vita
vita added a note

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@parndt parndt merged commit a0069f4 into refinery:master
@parndt
Owner

Merged, thank you @vita !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2012
  1. @vita
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 8 deletions.
  1. +10 −8 pages/app/models/refinery/page.rb
View
18 pages/app/models/refinery/page.rb
@@ -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)
@parndt Owner
parndt added a note

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

@vita
vita added a note

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ [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
Something went wrong with that request. Please try again.