Skip to content

Commit

Permalink
Removing final parts of old cache system.
Browse files Browse the repository at this point in the history
  • Loading branch information
reines committed Feb 28, 2011
1 parent d0afe45 commit c0d9338
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 99 deletions.
2 changes: 1 addition & 1 deletion db_update.php
Expand Up @@ -1785,7 +1785,7 @@ function _error_users($cur_user)
update_forum($row[0]);

// Empty the PHP cache
forum_clear_cache();
@$cache->clear();

// Delete the update lock file
@unlink(FORUM_CACHE_DIR.'db_update.lock');
Expand Down
14 changes: 2 additions & 12 deletions extern.php
Expand Up @@ -505,18 +505,8 @@ function output_html($feed)
// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php';

// Collect some statistics from the database
if (file_exists(FORUM_CACHE_DIR.'cache_users_info.php'))
include FORUM_CACHE_DIR.'cache_users_info.php';

if (!defined('PUN_USERS_INFO_LOADED'))
{
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';

generate_users_info_cache();
require FORUM_CACHE_DIR.'cache_users_info.php';
}
// Collect some board statistics
$stats = fetch_board_stats();

$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
Expand Down
43 changes: 0 additions & 43 deletions include/cache.php

This file was deleted.

40 changes: 25 additions & 15 deletions include/functions.php
Expand Up @@ -7,6 +7,31 @@
*/


//
// Collect some board statistics
//
function fetch_board_stats()
{
global $cache, $db;

$stats = $cache->get('boardstats');
if ($stats === Cache::NOT_FOUND)
{
$stats = array();

$result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED) or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
$stats['total_users'] = $db->result($result);

$result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED.' ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);

$cache->set('boardstats', $stats);
}

return $stats;
}


//
// Return current timestamp (with microseconds) as a float
//
Expand Down Expand Up @@ -728,21 +753,6 @@ function delete_post($post_id, $topic_id)
}


//
// Delete every .php file in the forum's cache directory
//
function forum_clear_cache()
{
$d = dir(FORUM_CACHE_DIR);
while (($entry = $d->read()) !== false)
{
if (substr($entry, -4) == '.php')
@unlink(FORUM_CACHE_DIR.$entry);
}
$d->close();
}


//
// Replace censored words in $text
//
Expand Down
14 changes: 2 additions & 12 deletions index.php
Expand Up @@ -171,18 +171,8 @@
else
echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>';

// Collect some statistics from the database
if (file_exists(FORUM_CACHE_DIR.'cache_users_info.php'))
include FORUM_CACHE_DIR.'cache_users_info.php';

if (!defined('PUN_USERS_INFO_LOADED'))
{
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';

generate_users_info_cache();
require FORUM_CACHE_DIR.'cache_users_info.php';
}
// Collect some board statistics
$stats = fetch_board_stats();

$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
Expand Down
5 changes: 1 addition & 4 deletions login.php
Expand Up @@ -69,10 +69,7 @@
$db->query('UPDATE '.$db->prefix.'users SET group_id='.$pun_config['o_default_user_group'].' WHERE id='.$cur_user['id']) or error('Unable to update user status', __FILE__, __LINE__, $db->error());

// Regenerate the users info cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';

generate_users_info_cache();
$cache->clear('boardstats');
}

// Remove this users guest entry from the online list
Expand Down
10 changes: 2 additions & 8 deletions profile.php
Expand Up @@ -445,10 +445,7 @@
$db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group_id.' WHERE id='.$id) or error('Unable to change user group', __FILE__, __LINE__, $db->error());

// Regenerate the users info cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';

generate_users_info_cache();
$cache->clear('boardstats');

$result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$new_group_id) or error('Unable to fetch group', __FILE__, __LINE__, $db->error());
$new_group_mod = $db->result($result);
Expand Down Expand Up @@ -607,10 +604,7 @@
delete_avatar($id);

// Regenerate the users info cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';

generate_users_info_cache();
$cache->clear('boardstats');

redirect('index.php', $lang_profile['User delete redirect']);
}
Expand Down
5 changes: 1 addition & 4 deletions register.php
Expand Up @@ -220,10 +220,7 @@
}

// Regenerate the users info cache
if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
require PUN_ROOT.'include/cache.php';

generate_users_info_cache();
$cache->clear('boardstats');

pun_setcookie($new_uid, $password_hash, time() + $pun_config['o_timeout_visit']);

Expand Down

0 comments on commit c0d9338

Please sign in to comment.