Delete caches and optimize tables on upgrade

git-svn-id: http://piwigo.org/svn/trunk@2890 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rub 2008-11-19 20:03:49 +00:00
commit e41325376b
3 changed files with 25 additions and 7 deletions

View file

@ -1762,12 +1762,24 @@ function pwg_URL()
/**
* Invalidates cahed data (permissions and category counts) for all users.
*/
function invalidate_user_cache()
function invalidate_user_cache($full = true)
{
$query = '
if ($full)
{
$query = '
TRUNCATE TABLE '.USER_CACHE_CATEGORIES_TABLE.';';
pwg_query($query);
$query = '
TRUNCATE TABLE '.USER_CACHE_TABLE.';';
pwg_query($query);
}
else
{
$query = '
UPDATE '.USER_CACHE_TABLE.'
SET need_update = \'true\'';
pwg_query($query);
SET need_update = \'true\';';
pwg_query($query);
}
trigger_action('invalidate_user_cache');
}

View file

@ -46,7 +46,7 @@ switch ($action)
update_uppercats();
update_category('all');
update_global_rank();
invalidate_user_cache();
invalidate_user_cache(true);
break;
}
case 'images' :

View file

@ -298,8 +298,6 @@ if (isset($_POST['submit']) and check_upgrade())
l10n('perform a maintenance check')
);
invalidate_user_cache();
// c13y_upgrade plugin means "check integrity after upgrade", so it
// becomes useful just after an upgrade
$query = '
@ -308,6 +306,14 @@ REPLACE INTO '.PLUGINS_TABLE.'
VALUES (\'c13y_upgrade\', \'active\')
;';
pwg_query($query);
// Delete cache data
invalidate_user_cache(true);
$template->delete_compiled_templates();
// Tables Maintenance
do_maintenance_all_tables();
}
}