Changeset 1809

Show
Ignore:
Timestamp:
04/08/08 17:29:46 (8 months ago)
Author:
bchoate
Message:

Memoize mtlink tag.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-34/php/lib/function.mtlink.php

    r1174 r1809  
    99    // status: incomplete 
    1010    // parameters: template, entry_id 
     11    static $_template_links = array(); 
    1112    if (isset($args['template'])) { 
    1213        $name = $args['template']; 
    13         $tmpl = $ctx->mt->db->load_index_template($ctx, $name); 
    14         $blog = $ctx->stash('blog'); 
    15         $site_url = $blog['blog_site_url']; 
    16         if (!preg_match('!/$!', $site_url)) $site_url .= '/'; 
    17         $link = $site_url . $tmpl['template_outfile']; 
     14        $cache_key = $ctx->__stash['blog_id'] . ';' . $name; 
     15        if (isset($_template_links[$cache_key])) { 
     16            $link = $_template_links[$cache_key]; 
     17        } else { 
     18            $tmpl = $ctx->mt->db->load_index_template($ctx, $name); 
     19            $blog = $ctx->stash('blog'); 
     20            $site_url = $blog['blog_site_url']; 
     21            if (!preg_match('!/$!', $site_url)) $site_url .= '/'; 
     22            $link = $site_url . $tmpl['template_outfile']; 
     23            $_template_links[$cache_key] = $link; 
     24        } 
    1825        if (!$args['with_index']) { 
    1926            $link = _strip_index($link, $blog); 
     
    3946    return ''; 
    4047} 
    41 ?>