Index: branches/5.0.x/core/kernel/languages/phrases_cache.php =================================================================== diff -u -r12345 -r12389 --- branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12345) +++ branches/5.0.x/core/kernel/languages/phrases_cache.php (.../phrases_cache.php) (revision 12389) @@ -1,6 +1,6 @@ OriginalIds = $ids; } - function AddCachedPhrase($label, $value) + function AddCachedPhrase($label, $value, $allow_editing = true) { - $label = mb_strtoupper($label); - $this->Phrases[$label] = $value; + $cache_key = ($allow_editing ? '' : 'NE:') . $label; + + $this->Phrases[$cache_key] = $value; } function NeedsCacheUpdate() @@ -206,7 +207,7 @@ } if (ereg("^!.+!$", $label) > 0) { - $label = substr($label, 1, -1); //cut exclamation marks + $label = substr($label, 1, -1); // cut exclamation marks } if (strlen($label) == 0) { @@ -216,9 +217,11 @@ $original_label = $label; $label = mb_strtoupper($label); - if (array_key_exists($label, $this->Phrases)) { - $translated_label = $this->Phrases[$label]; + $cache_key = ($allow_editing ? '' : 'NE:') . $label; + if (array_key_exists($cache_key, $this->Phrases)) { + $translated_label = $this->Phrases[$cache_key]; + if ($this->_editExisting && $allow_editing && !array_key_exists($label, $this->_missingPhrases)) { // option to change translation for Labels $edit_url = 'javascript:translate_phrase(\'' . addslashes($original_label) . '\', \'' . $this->_phraseEditTemplate . '\', {event: \'OnPrepareUpdate\', simple_mode: ' . ($this->_simpleEditingMode ? 'true' : 'false') . '});'; @@ -239,9 +242,10 @@ function LoadPhraseByLabel($label, $original_label, $allow_editing = true) { + // bug: MySQL don't use index on Phrase column, when function is used on it's value (e.g. UPPER, like in this case) $sql = 'SELECT PhraseId, Translation FROM ' . TABLE_PREFIX . 'Phrase - WHERE (LanguageId = ' . $this->LanguageId . ') AND (UPPER(Phrase) = UPPER(' . $this->Conn->qstr($label) . '))'; + WHERE (LanguageId = ' . $this->LanguageId . ') AND (UPPER(Phrase) = ' . $this->Conn->qstr($label) . ')'; $res = $this->Conn->GetRow($sql); if ($res === false || count($res) == 0) { @@ -259,14 +263,17 @@ } // add it as already cached, as long as we dont need to cache not found phrase - $this->AddCachedPhrase($label, $translation); + $this->AddCachedPhrase($label, $translation, $allow_editing); return false; } - $this->Phrases[$label] = $res['Translation']; + $cache_key = ($allow_editing ? '' : 'NE:') . $label; + $this->Phrases[$cache_key] = $res['Translation']; + array_push($this->Ids, $res['PhraseId']); - $this->Ids = array_unique($this->Ids); //just to make sure + $this->Ids = array_unique($this->Ids); // just to make sure + return true; }