protected function advancedStringOverridesContext::ensureCacheLoaded in String Overrides Advanced 7
2 calls to advancedStringOverridesContext::ensureCacheLoaded()
- advancedStringOverridesContext::offsetExists in lib/
advancedStringsContext.inc - (PHP 5 >= 5.0.0)<br/> Whether a offset exists @link http://php.net/manual/en/arrayaccess.offsetexists.php
- advancedStringOverridesContext::offsetGet in lib/
advancedStringsContext.inc - (PHP 5 >= 5.0.0)<br/> Offset to retrieve @link http://php.net/manual/en/arrayaccess.offsetget.php
File
- lib/
advancedStringsContext.inc, line 110
Class
Code
protected function ensureCacheLoaded() {
if (!isset($this->cachedStrings)) {
if ($cache = cache_get($this
->getCacheKey(), $this
->getCacheBinName())) {
$this->cachedStrings = $cache->data;
}
elseif (lock_acquire($this
->getCacheKey())) {
// Refresh database stored cache of translations for given language.
// We only store short strings used in current version, to improve
// performance and consume less memory.
$result = db_query("SELECT s.source, t.translation, t.language FROM {stringoverrides_advanced_source} s LEFT JOIN {stringoverrides_advanced_target} t ON s.lid = t.lid AND t.language = :language WHERE s.textgroup = 'default' AND s.version = :version AND LENGTH(s.source) < :length AND s.context = :context", array(
':language' => $this
->getLangcode(),
':version' => VERSION,
':length' => variable_get('stringoverrides_advanced_cache_length', 75),
':context' => $this
->getContext(),
));
foreach ($result as $data) {
$this->cachedStrings[$data->source] = empty($data->translation) ? FALSE : $data->translation;
}
cache_set($this
->getCacheKey(), $this->cachedStrings, $this
->getCacheBinName());
lock_release($this
->getCacheKey());
}
}
}