From d496eb25298c444fbbe8bef4e720cab8930eedfb Mon Sep 17 00:00:00 2001 From: "mike.morgan%oregonstate.edu" Date: Tue, 21 Feb 2006 01:15:40 +0000 Subject: [PATCH] Caching touch-up. git-svn-id: svn://10.0.0.236/trunk@190638 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webtools/addons/public/htdocs/addon.php | 6 +- .../webtools/addons/public/htdocs/author.php | 4 +- .../addons/public/htdocs/extensions.php | 2 +- mozilla/webtools/addons/public/htdocs/faq.php | 2 +- .../webtools/addons/public/htdocs/history.php | 4 +- .../webtools/addons/public/htdocs/index.php | 2 +- .../webtools/addons/public/htdocs/policy.php | 2 +- .../addons/public/htdocs/previews.php | 2 +- mozilla/webtools/addons/public/htdocs/rss.php | 69 +++++++++---------- .../addons/public/htdocs/search-engines.php | 2 +- .../webtools/addons/public/htdocs/themes.php | 2 +- 11 files changed, 43 insertions(+), 54 deletions(-) diff --git a/mozilla/webtools/addons/public/htdocs/addon.php b/mozilla/webtools/addons/public/htdocs/addon.php index add08752a66..78d48ad5c8e 100644 --- a/mozilla/webtools/addons/public/htdocs/addon.php +++ b/mozilla/webtools/addons/public/htdocs/addon.php @@ -10,13 +10,9 @@ $clean['ID'] = intval($_GET['id']); $sql['ID'] =& $clean['ID']; -// Set the cachId so we have a unique cache for each AddOn ID. -$cacheId = $clean['ID']; - -startProcessing('addon.tpl',$cacheId,$compileId); +startProcessing('addon.tpl',$clean['ID'],$compileId); require_once('includes.php'); - // Create our AddOn object using the ID. $addon = new AddOn($sql['ID']); diff --git a/mozilla/webtools/addons/public/htdocs/author.php b/mozilla/webtools/addons/public/htdocs/author.php index 417d6bb3f2f..522bc568dd5 100644 --- a/mozilla/webtools/addons/public/htdocs/author.php +++ b/mozilla/webtools/addons/public/htdocs/author.php @@ -9,9 +9,7 @@ $clean['UserID'] = intval($_GET['id']); $sql['UserID'] =& $clean['UserID']; -$cacheId = $clean['UserID']; - -startProcessing('author.tpl',$cacheId,$compileId); +startProcessing('author.tpl',$clean['UserID'],$compileId); require_once('includes.php'); $user = new User($sql['UserID']); diff --git a/mozilla/webtools/addons/public/htdocs/extensions.php b/mozilla/webtools/addons/public/htdocs/extensions.php index c9bfdaaf96f..90dc846bcd4 100644 --- a/mozilla/webtools/addons/public/htdocs/extensions.php +++ b/mozilla/webtools/addons/public/htdocs/extensions.php @@ -8,7 +8,7 @@ $currentTab = 'extensions'; -startProcessing('extensions.tpl', null, $compileId); +startProcessing('extensions.tpl', 'extensions', $compileId); require_once('includes.php'); // If app is not set or empty, set it to null for our switch. diff --git a/mozilla/webtools/addons/public/htdocs/faq.php b/mozilla/webtools/addons/public/htdocs/faq.php index 79cf23974f7..c84c5f56e6e 100644 --- a/mozilla/webtools/addons/public/htdocs/faq.php +++ b/mozilla/webtools/addons/public/htdocs/faq.php @@ -8,7 +8,7 @@ * @todo FAQ search? */ -startProcessing('faq.tpl',null,$compileId); +startProcessing('faq.tpl','faq',$compileId); require_once('includes.php'); $db->query(" diff --git a/mozilla/webtools/addons/public/htdocs/history.php b/mozilla/webtools/addons/public/htdocs/history.php index 9b30bdcf316..43089995c20 100644 --- a/mozilla/webtools/addons/public/htdocs/history.php +++ b/mozilla/webtools/addons/public/htdocs/history.php @@ -14,9 +14,7 @@ $clean['ID'] = intval($_GET['id']); $sql['ID'] =& $clean['ID']; -$cacheId = $clean['ID']; - -startProcessing('history.tpl',$cacheId,$compileId); +startProcessing('history.tpl',$clean['ID'],$compileId); require_once('includes.php'); $addon = new AddOn($sql['ID']); diff --git a/mozilla/webtools/addons/public/htdocs/index.php b/mozilla/webtools/addons/public/htdocs/index.php index c0cdfde23c9..677a6d213ee 100644 --- a/mozilla/webtools/addons/public/htdocs/index.php +++ b/mozilla/webtools/addons/public/htdocs/index.php @@ -8,7 +8,7 @@ $currentTab = 'home'; -startProcessing('index.tpl', null, $compileId, 'nonav'); +startProcessing('index.tpl', 'home', $compileId, 'nonav'); require_once('includes.php'); // If app is not set or empty, set it to null for our switch. diff --git a/mozilla/webtools/addons/public/htdocs/policy.php b/mozilla/webtools/addons/public/htdocs/policy.php index 997a62c366e..041281b9310 100644 --- a/mozilla/webtools/addons/public/htdocs/policy.php +++ b/mozilla/webtools/addons/public/htdocs/policy.php @@ -8,7 +8,7 @@ * @todo talk to cbeard and rebron about establishing the policy document. */ -startProcessing('policy.tpl',null,$compileId); +startProcessing('policy.tpl','policy',$compileId); require_once('includes.php'); $links = array( diff --git a/mozilla/webtools/addons/public/htdocs/previews.php b/mozilla/webtools/addons/public/htdocs/previews.php index f61a7a1e7c8..f9af1655e55 100644 --- a/mozilla/webtools/addons/public/htdocs/previews.php +++ b/mozilla/webtools/addons/public/htdocs/previews.php @@ -10,7 +10,7 @@ $clean['ID'] = intval($_GET['id']); $sql['ID'] =& $clean['ID']; -startProcessing('previews.tpl',$cacheId,$compileId); +startProcessing('previews.tpl',$clean['ID'],$compileId); require_once('includes.php'); $addon = new AddOn($sql['ID']); diff --git a/mozilla/webtools/addons/public/htdocs/rss.php b/mozilla/webtools/addons/public/htdocs/rss.php index 057d2682ed5..babcac0c311 100644 --- a/mozilla/webtools/addons/public/htdocs/rss.php +++ b/mozilla/webtools/addons/public/htdocs/rss.php @@ -6,6 +6,33 @@ * @subpackage docs */ + + +/** + * CHECK CACHE + * + * Check to see if we already have a matching cacheId. + * If it exists, we can pull from it and exit; and avoid recompiling. + */ +// Determine a cacheId based on params. +$cacheId = md5($_SERVER['QUERY_STRING']); + +$tpl = new AMO_Smarty(); + +// Set our cache timeout to 2 hours, which is reasonable. +$tpl->caching = 1; +$tpl->cache_timeout = 7200; + +// Determine our cacheId based on the RSS feed's arguments. + +if ($tpl->is_cached('rss.tpl',$cacheId)) { + header('Content-Type: text/xml; charset=utf-8'); + $tpl->display('rss.tpl',$cacheId); + exit; +} + + + /** * Pull our input params. */ @@ -56,35 +83,12 @@ switch (strtolower($rsslist)) { break; } -// Generate our cache_id. -$cache_id = md5($rssapp.$rsstype.$rsslist); - unset($rssapp); unset($rsstype); unset($rsslist); -/** - * CHECK CACHE - * - * Check to see if we already have a matching cache_id. - * If it exists, we can pull from it and exit; and avoid recompiling. - */ -$tpl = new AMO_Smarty(); - -// Set our cache timeout to 2 hours, which is reasonable. -$tpl->caching = 1; -$tpl->cache_timeout = 7200; - -// Determine our cache_id based on the RSS feed's arguments. - -if ($tpl->is_cached('rss.tpl',$cache_id)) { - header('Content-Type: text/xml; charset=utf-8'); - $tpl->display('rss.tpl',$cache_id); - exit; -} - // If we get here, we're going to have to pull DB contents. require_once('includes.php'); @@ -93,7 +97,7 @@ $sql['app'] = $clean['app']; // Already ok for sql, type was checked (alpha). $sql['type'] = $clean['type']; // Already ok for sql, type was checked (alpha). $_rssSql = " - SELECT DISTINCT + SELECT m.id, m.name as title, m.type, @@ -104,20 +108,13 @@ $_rssSql = " a.appname FROM main m - INNER JOIN - version v - ON - v.id = m.id - INNER JOIN - applications a - ON - a.appid = v.appid + INNER JOIN version v ON v.id = m.id + INNER JOIN applications a ON a.appid = v.appid WHERE v.approved = 'yes' AND a.appname = '{$sql['app']}' AND - m.type = '{$sql['type']}' - GROUP BY - m.id + m.type = '{$sql['type']}' AND + v.vid = (SELECT max(vid) FROM version WHERE id=m.id AND approved='YES') ORDER BY {$rssOrderBy} LIMIT 0,10 @@ -130,6 +127,6 @@ $tpl->assign('data',$_rssData); // Set our content-type and spit it out. header('Content-Type: text/xml; charset=utf-8'); -$tpl->display('rss.tpl',$cache_id); +$tpl->display('rss.tpl',$cacheId); exit; ?> diff --git a/mozilla/webtools/addons/public/htdocs/search-engines.php b/mozilla/webtools/addons/public/htdocs/search-engines.php index 6aa053dd9bb..4c9683b3f76 100644 --- a/mozilla/webtools/addons/public/htdocs/search-engines.php +++ b/mozilla/webtools/addons/public/htdocs/search-engines.php @@ -11,7 +11,7 @@ $currentTab = 'search-engines'; -startProcessing('search-engines.tpl',null,$compileId,'nonav'); +startProcessing('search-engines.tpl','searchEngines',$compileId,'nonav'); require_once('includes.php'); // Assign template variables. diff --git a/mozilla/webtools/addons/public/htdocs/themes.php b/mozilla/webtools/addons/public/htdocs/themes.php index 81bd17a1769..63e4becb5e4 100644 --- a/mozilla/webtools/addons/public/htdocs/themes.php +++ b/mozilla/webtools/addons/public/htdocs/themes.php @@ -8,7 +8,7 @@ $currentTab = 'themes'; -startProcessing('themes.tpl', null, $compileId); +startProcessing('themes.tpl', 'themes', $compileId); require_once('includes.php'); // If app is not set or empty, set it to null for our switch.