diff --git a/doc/htconfig.md b/doc/htconfig.md index 296551244c..ef57380197 100644 --- a/doc/htconfig.md +++ b/doc/htconfig.md @@ -37,6 +37,7 @@ Example: To set the automatic database cleanup process add this line to your .ht * **db_loglimit_index** - Number of index rows needed to be logged for indexes on the watchlist * **db_loglimit_index_high** - Number of index rows to be logged anyway (for any index) * **db_log_index_blacklist** - Blacklist of indexes that shouldn't be watched +* **dbclean_expire_conversation** (Integer) - When DBClean is enabled, any entry in the conversation table will be deleted after this many days. These data are normally needed only for debugging purposes and they are safe to delete. Default 90. * **diaspora_test** (Boolean) - For development only. Disables the message transfer. * **disable_email_validation** (Boolean) - Disables the check if a mail address is in a valid format and can be resolved via DNS. * **disable_url_validation** (Boolean) - Disables the DNS lookup of an URL. diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php index 20691c178e..ffeee5dd68 100644 --- a/src/Worker/DBClean.php +++ b/src/Worker/DBClean.php @@ -323,11 +323,12 @@ class DBClean { Config::set('system', 'dbclean-last-id-9', $last_id); } elseif ($stage == 10) { $last_id = Config::get('system', 'dbclean-last-id-10', 0); + $days = intval(Config::get('system', 'dbclean_expire_conversation', 90)); logger("Deleting old conversations. Last created: ".$last_id); $r = dba::p("SELECT `received`, `item-uri` FROM `conversation` - WHERE `received` < UTC_TIMESTAMP() - INTERVAL 90 DAY - ORDER BY `received` LIMIT ".intval($limit)); + WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY + ORDER BY `received` LIMIT ?", $days, intval($limit)); $count = dba::num_rows($r); if ($count > 0) { logger("found old conversations: ".$count);