From 282c5108d804b90db547381c4ed770add3f78513 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 21 Dec 2004 01:08:27 +0000 Subject: [PATCH] r8: Added version and product/component caches to save queries in newreport.php. --- admin/product.php | 14 ++++++++++- docs/recache.php | 8 +++++++ includes/functions_datastore.php | 40 ++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/admin/product.php b/admin/product.php index 09b7ceb..a094b10 100755 --- a/admin/product.php +++ b/admin/product.php @@ -11,6 +11,7 @@ \*=====================================================================*/ require_once('./global.php'); +require_once('./includes/functions_datastore.php'); if (!($bugsys->userinfo['permissions'] & CANADMINVERSIONS)) { @@ -68,6 +69,8 @@ if ($_REQUEST['do'] == 'killversion') $DB_sql->query("DELETE FROM " . TABLE_PREFIX . "version WHERE versionid = $vars[versionid]"); // #*# figure out what we do with bugs + build_versions(); + $admin->redirect('product.php?do=modify'); } @@ -85,6 +88,7 @@ if ($_REQUEST['do'] == 'insertversion') { sanitize(array('productid' => INT, 'version' => STR, 'displayorder' => INT)); $DB_sql->query("INSERT INTO " . TABLE_PREFIX . "version (productid, version, displayorder) VALUES ($vars[productid], '" . addslasheslike($vars['version']) . "', $vars[displayorder])"); + build_versions(); $admin->redirect('product.php?do=modify'); } @@ -134,6 +138,7 @@ if ($_REQUEST['do'] == 'updateversion') } $DB_sql->query("UPDATE " . TABLE_PREFIX . "version SET version = '" . addslasheslike($vars['version']) . "', displayorder = $vars[displayorder] WHERE versionid = $vars[versionid]"); + build_versions(); $admin->redirect('product.php?do=modify'); } @@ -181,6 +186,8 @@ if ($_REQUEST['do'] == 'killproduct') $DB_sql->query("DELETE FROM " . TABLE_PREFIX . "version WHERE productid IN (" . implode(', ', $list) . ")"); // #*# do bug kills here + build_products(); + $admin->redirect('product.php?do=modify'); } @@ -208,7 +215,9 @@ if ($_REQUEST['do'] == 'insertproduct') (shortname, title, componentmother, description, displayorder) VALUES ('" . addslasheslike($vars['shortname']) . "', '" . addslasheslike($vars['title']) . "', - $vars[componentmother], '" . addslasheslike($vars['description']) . "', $vars[displayorder])"); + $vars[componentmother], '" . addslasheslike($vars['description']) . "', $vars[displayorder])" + ); + build_products(); $admin->redirect('product.php?do=modify'); } @@ -253,6 +262,7 @@ if ($_REQUEST['do'] == 'updateproduct') } $DB_sql->query("UPDATE " . TABLE_PREFIX . "product SET title = '" . addslasheslike($vars['title']) . "', shortname = '" . addslasheslike($vars['shortname']) . "', description = '" . addslasheslike($vars['description']) . "', displayorder = $vars[displayorder] WHERE productid = $vars[productid]"); + build_products(); $admin->redirect('product.php?do=modify'); } @@ -301,6 +311,8 @@ if ($_POST['do'] == 'displayorder') $DB_sql->query("UPDATE " . TABLE_PREFIX . "$name[0] SET displayorder = $order WHERE $name[0]id = $id"); } } + build_products(); + build_versions(); $admin->redirect('product.php?do=modify'); } diff --git a/docs/recache.php b/docs/recache.php index a8a9ac5..453f1e1 100755 --- a/docs/recache.php +++ b/docs/recache.php @@ -36,6 +36,14 @@ build_resolutions(); echo '

Resolutions cached

'; +build_versions(); + +echo '

Versions cached

'; + +build_products(); + +echo '

Products cached

'; + // $Id$ ?> \ No newline at end of file diff --git a/includes/functions_datastore.php b/includes/functions_datastore.php index 493b3c2..8238ac0 100755 --- a/includes/functions_datastore.php +++ b/includes/functions_datastore.php @@ -176,6 +176,46 @@ function build_resolutions() $bugsys->datastore['resolution'] = $tempstore; } +// ####################### Start build_versions ###################### +function build_versions() +{ + global $DB_sql, $bugsys; + + $versions = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC"); + while ($version = $DB_sql->fetch_array($versions)) + { + $tempstore["$version[versionid]"] = $version; + } + + $DB_sql->query(" + ### replacing version cache ### + REPLACE INTO " . TABLE_PREFIX . "datastore (title, data) + VALUES ('version', '" . addslasheslike(serialize($tempstore)) . "')" + ); + + $bugsys->datastore['version'] = $tempstore; +} + +// ####################### Start build_products ###################### +function build_products() +{ + global $DB_sql, $bugsys; + + $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC"); + while ($product = $DB_sql->fetch_array($products)) + { + $tempstore["$product[productid]"] = $product; + } + + $DB_sql->query(" + ### replacing product / component cache ### + REPLACE INTO " . TABLE_PREFIX . "datastore (title, data) + VALUES ('product', '" . addslasheslike(serialize($tempstore)) . "')" + ); + + $bugsys->datastore['product'] = $tempstore; +} + /*=====================================================================*\ || ################################################################### || # $HeadURL$ -- 2.22.5