Fixes #239, cacheKeyComponent updates cache key when filtering is disabled

This commit is contained in:
Conrad 2016-04-04 15:10:24 +12:00
parent e84b61246e
commit 07bd3c58cb
2 changed files with 10 additions and 1 deletions

View File

@ -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';
}
/**

View File

@ -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() {