summaryrefslogtreecommitdiffstats
path: root/web/lib/stats.inc
diff options
context:
space:
mode:
authorLoui Chang <louipc.ist@gmail.com>2009-01-08 19:08:58 +0100
committerLoui Chang <louipc.ist@gmail.com>2009-01-08 19:08:58 +0100
commit2da9b55d9fb30f8da124dce4ed8d49af11bd5523 (patch)
tree24624325b56d30c26fd142328beaa4598f7999b0 /web/lib/stats.inc
parent649517ac1f1620752583df5664c4f836101f63d6 (diff)
downloadaur-2da9b55d9fb30f8da124dce4ed8d49af11bd5523.tar.gz
aur-2da9b55d9fb30f8da124dce4ed8d49af11bd5523.tar.xz
Fix stats functionality when APC is unavailable.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web/lib/stats.inc')
-rw-r--r--web/lib/stats.inc14
1 files changed, 11 insertions, 3 deletions
diff --git a/web/lib/stats.inc b/web/lib/stats.inc
index e2b7f90f..7916f055 100644
--- a/web/lib/stats.inc
+++ b/web/lib/stats.inc
@@ -2,10 +2,10 @@
include_once('aur.inc');
+$apc_prefix = 'aur:';
# Check if APC extension is loaded
if (!defined('EXTENSION_LOADED_APC'))
define('EXTENSION_LOADED_APC', extension_loaded('apc'));
-$apc_prefix = 'aur:';
# run a simple db query, retrieving and/or caching the value if APC
# is available for use
@@ -17,13 +17,17 @@ function db_cache_value($dbq, $dbh, $key)
$row = mysql_fetch_row($result);
$ret = $row[0];
# set the TTL here in seconds: 300 seconds = 5 minutes
- apc_store($key, $ret, 300);
+
+ if (EXTENSION_LOADED_APC) {
+ apc_store($key, $ret, 300);
+ }
}
return $ret;
}
function updates_table($dbh)
{
+ global $apc_prefix;
$key = $apc_prefix . 'recent_updates';
if(!(EXTENSION_LOADED_APC && ($newest_packages = apc_fetch($key)))) {
$q = 'SELECT * FROM Packages WHERE DummyPkg != 1 ORDER BY GREATEST(SubmittedTS,ModifiedTS) DESC LIMIT 0 , 10';
@@ -33,7 +37,10 @@ function updates_table($dbh)
while ($row = mysql_fetch_assoc($result)) {
$newest_packages->append($row);
}
- apc_store($key, $newest_packages, 300);
+
+ if (EXTENSION_LOADED_APC) {
+ apc_store($key, $newest_packages, 300);
+ }
}
include('stats/updates_table.php');
}
@@ -69,6 +76,7 @@ function user_table($user, $dbh)
function general_stats_table($dbh)
{
+ global $apc_prefix;
# AUR statistics
$q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported'";
$unsupported_count = db_cache_value($q, $dbh, $apc_prefix . 'unsupported_count');