Index: branches/5.2.x/core/units/helpers/mod_rewrite_helper.php =================================================================== diff -u -N -r14095 -r14184 --- branches/5.2.x/core/units/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 14095) +++ branches/5.2.x/core/units/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 14184) @@ -1,6 +1,6 @@ Application->VerifyThemeId(); $this->Application->VerifyLanguageId(); - $this->Application->Phrases->Init('phrases'); + + // no need, since we don't have any cached phrase IDs + nobody will use PhrasesCache::LanguageId soon + // $this->Application->Phrases->Init('phrases'); } /** @@ -347,7 +349,7 @@ do { $template_path = implode('/', $url_parts); - $physical_template = array_search($template_path, $this->Application->structureTemplateMapping); + $physical_template = $this->Application->getPhysicalTemplate($template_path); if (($physical_template !== false) && (substr($physical_template, 0, 3) != 'id:')) { // replace menu template name with it's actual template name on disk @@ -831,7 +833,7 @@ $ret .= 'bb_' . $processed_params[$prefix_special . '_id'] . '/'; } else { - $filename = $this->Application->getFilename($prefix, $processed_params[$prefix_special . '_id'], $category_id); + $filename = $this->getFilename($prefix, $processed_params[$prefix_special . '_id'], $category_id); if ($filename !== false) { $ret .= $filename . '/'; } @@ -858,6 +860,48 @@ } /** + * Returns item's filename that corresponds id passed. If possible, then get it from cache + * + * @param string $prefix + * @param int $id + * @param int $category_id + * @return string + */ + function getFilename($prefix, $id, $category_id = null) + { + if ($prefix == 'c') { + throw new Exception('Method "' . __FUNCTION__ . '" no longer work with "c" prefix. Please use "getCategoryCache" method instead'); + + return false; + } + + $category_id = isset($category_id) ? $category_id : $this->Application->GetVar('m_cat_id'); + + $cache_key = 'filenames[%' . $this->Application->incrementCacheSerial($prefix, $id, false) . '%]:' . (int)$category_id; + $filename = $this->Application->getCache($cache_key); + + if ($filename === false) { + $this->Conn->nextQueryCachable = true; + $sql = 'SELECT ResourceId + FROM ' . $this->Application->getUnitOption($prefix, 'TableName') . ' + WHERE ' . $this->Application->getUnitOption($prefix, 'IDField') . ' = ' . $this->Conn->qstr($id); + $resource_id = $this->Conn->GetOne($sql); + + $this->Conn->nextQueryCachable = true; + $sql = 'SELECT Filename + FROM ' . TABLE_PREFIX . 'CategoryItems + WHERE (ItemResourceId = ' . $resource_id . ') AND (CategoryId = ' . (int)$category_id . ')'; + $filename = $this->Conn->GetOne($sql); + + if ($filename !== false) { + $this->Application->setCache($cache_key, $filename); + } + } + + return $filename; + } + + /** * Sets template and id, corresponding to category item given in url * * @param Array $url_parts