mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
fixes #553 smartly remove the old history.summarized column
Only when we have as few lines as possible in the history table, not before.
This commit is contained in:
@@ -400,6 +400,7 @@ SELECT
|
||||
|
||||
if ($count <= $conf['history_autopurge_keep_lines'])
|
||||
{
|
||||
history_remove_summarized_column();
|
||||
return; // no need to purge for now
|
||||
}
|
||||
|
||||
@@ -463,6 +464,39 @@ DELETE
|
||||
WHERE id < '.$history_id_delete_before.'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
history_remove_summarized_column();
|
||||
}
|
||||
|
||||
function history_remove_summarized_column()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (isset($conf['history_summarized_dropped']) and $conf['history_summarized_dropped'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM '.HISTORY_TABLE.'
|
||||
;';
|
||||
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
if ($count > $conf['history_autopurge_keep_lines']+$conf['history_autopurge_blocksize'])
|
||||
{
|
||||
// it's not yet time to remove history.summarized
|
||||
return;
|
||||
}
|
||||
|
||||
$result = pwg_query('SHOW COLUMNS FROM `'.HISTORY_TABLE.'` LIKE "summarized";');
|
||||
if (pwg_db_num_rows($result))
|
||||
{
|
||||
pwg_query('ALTER TABLE `'.HISTORY_TABLE.'` DROP COLUMN `summarized`;');
|
||||
}
|
||||
|
||||
conf_update_param('history_summarized_dropped', true);
|
||||
}
|
||||
|
||||
add_event_handler('get_history', 'get_history');
|
||||
|
||||
Reference in New Issue
Block a user