mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Fixes #239, cacheKeyComponent updates cache key when filtering is disabled
This commit is contained in:
parent
e84b61246e
commit
07bd3c58cb
@ -1811,7 +1811,7 @@ class Translatable extends DataExtension implements PermissionProvider {
|
||||
* Return a piece of text to keep DataObject cache keys appropriately specific
|
||||
*/
|
||||
function cacheKeyComponent() {
|
||||
return 'locale-'.self::get_current_locale();
|
||||
return self::locale_filter_enabled() ? 'locale-'.self::get_current_locale() : 'locale-filter-disabled';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,6 +100,15 @@ class TranslatableTest extends FunctionalTest {
|
||||
);
|
||||
$this->assertEquals($translated->ID, $found->ID);
|
||||
Translatable::enable_locale_filter();
|
||||
|
||||
//test caching of get_one when filtering is disabled
|
||||
Translatable::set_current_locale('de_DE'); //cache failed lookup
|
||||
$notFound = DataObject::get_one('SiteTree', '"URLSegment" = \'home\'');
|
||||
$this->assertFalse($notFound, 'Should not have found a home page for de_DE');
|
||||
Translatable::disable_locale_filter();
|
||||
$found = DataObject::get_one('SiteTree', '"URLSegment" = \'home\'');
|
||||
$this->assertInstanceOf('DataObject', $found, 'Should have found a home page with locale filtering off');
|
||||
Translatable::enable_locale_filter();
|
||||
}
|
||||
|
||||
function testLocaleFilteringEnabledAndDisabled() {
|
||||
|
Loading…
Reference in New Issue
Block a user