Estuve viendo en vBulletin 3.6 de la cual tengo licencia
Código PHP:
Ver originalfunction cache_templates($templates, $templateidlist)
{
global $vbulletin, $templateassoc;
if (empty($templateassoc)) {
}
if ($vbulletin->options['legacypostbit'] AND
in_array('postbit', $templates)) {
$templateassoc['postbit'] = $templateassoc['postbit_legacy'];
}
foreach ($templates AS $template)
{
$templateids[] = intval($templateassoc["$template"]); }
if (!empty($templateids)) {
// run query
$temps = $vbulletin->db->query_read_slave("
SELECT title, template
FROM " . TABLE_PREFIX . "template
WHERE templateid IN (" . implode(',', $templateids) . ") ");
// cache templates
while ($temp = $vbulletin->db->fetch_array($temps))
{
if (empty($vbulletin->templatecache["$temp[title]"])) {
$vbulletin->templatecache["$temp[title]"] = $temp['template'];
}
}
$vbulletin->db->free_result($temps);
}
$vbulletin->bbcode_style = array( 'code' => &$templateassoc['bbcode_code_styleid'],
'html' => &$templateassoc['bbcode_html_styleid'],
'php' => &$templateassoc['bbcode_php_styleid'],
'quote' => &$templateassoc['bbcode_quote_styleid']
);
}
// #############################################################################
/**
* Returns a single template from the templatecache or the database
*
* @param string Name of template to be fetched
* @param integer Escape quotes in template? 1: escape template; -1: unescape template; 0: do nothing
* @param boolean Wrap template in HTML comments showing the template name?
*
* @return string
*/
function fetch_template($templatename, $escape = 0, $gethtmlcomments = true)
{
// gets a template from the db or from the local cache
global $style, $vbulletin, $tempusagecache, $templateassoc;
// use legacy postbit if necessary
if ($vbulletin->options['legacypostbit'] AND $templatename == 'postbit')
{
$templatename = 'postbit_legacy';
}
if (isset($vbulletin->templatecache["$templatename"])) {
$template = $vbulletin->templatecache["$templatename"];
}
else
{
DEVDEBUG("Uncached template: $templatename");
$GLOBALS['_TEMPLATEQUERIES']["$templatename"] = true;
$fetch_tid = intval($templateassoc["$templatename"]); if (!$fetch_tid)
{
$gettemp = array('template' => ''); }
else
{
$gettemp = $vbulletin->db->query_first_slave("
SELECT template
FROM " . TABLE_PREFIX . "template
WHERE templateid = $fetch_tid
");
}
$template = $gettemp['template'];
$vbulletin->templatecache["$templatename"] = $template;
}
// **************************
/*
if ($template == '<<< FILE >>>')
{
$template = addslashes(implode('', file("./templates/$templatename.html")));
$vbulletin->templatecache["$templatename"] = $template;
}
*/
// **************************
switch($escape)
{
case 1:
// escape template
break;
case -1:
// unescape template
break;
}
if (isset($tempusagecache["$templatename"])) {
++$tempusagecache["$templatename"];
}
else
{
$tempusagecache["$templatename"] = 1;
}
if ($vbulletin->options['addtemplatename'] AND $gethtmlcomments)
{
$templatename = preg_replace('#[^a-z0-9_]#i', '', $templatename); return "<!-- BEGIN TEMPLATE: $templatename -->\n$template\n<!-- END TEMPLATE: $templatename -->";
}
return $template;
}
Si te fijas el "cacheo" lo hace al obtener de la base de datos los templates y guardarlos en un array, tu crees que con guardarlo en un array, sea suficiente para decir que esta guardado en cache ? Tomando parte del codigo anterior,
o hay alguna otra cosa que hace para guardar en cache?
Código PHP:
Ver original// cache templates
while ($temp = $vbulletin->db->fetch_array($temps))
{
if (empty($vbulletin->templatecache["$temp[title]"])) {
$vbulletin->templatecache["$temp[title]"] = $temp['template'];
}
}