From: Alexander Ebert Date: Thu, 13 Dec 2018 13:59:16 +0000 (+0100) Subject: Missing time check for ip address pruning X-Git-Tag: 5.2.0_Alpha_1~434 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f3596681a1f2ca2898e231d9274fcb821b8fb196;p=GitHub%2FWoltLab%2FWCF.git Missing time check for ip address pruning See #2656 --- diff --git a/wcfsetup/install/files/lib/system/cronjob/PruneIpAddressesCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/PruneIpAddressesCronjob.class.php index 48f7c0da05..addbcd8f58 100644 --- a/wcfsetup/install/files/lib/system/cronjob/PruneIpAddressesCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/PruneIpAddressesCronjob.class.php @@ -6,14 +6,20 @@ use wcf\system\WCF; /** * Prunes old ip addresses. * - * @author Alexander Ebert - * @copyright 2001-2018 WoltLab GmbH - * @license GNU Lesser General Public License - * @package WoltLabSuite\Core\System\Cronjob + * @author Alexander Ebert + * @copyright 2001-2018 WoltLab GmbH + * @license GNU Lesser General Public License + * @package WoltLabSuite\Core\System\Cronjob + * @since 3.2 */ class PruneIpAddressesCronjob extends AbstractCronjob { /** - * list of columns grouped by the corresponding table + * list of columns + * [ + * => [ + * => + * ] + * ] * @var string[][] */ public $columns = []; @@ -24,22 +30,21 @@ class PruneIpAddressesCronjob extends AbstractCronjob { public function execute(Cronjob $cronjob) { if (!PRUNE_IP_ADDRESS) return; - $this->columns['wcf'.WCF_N.'_user'][] = 'registrationIpAddress'; + $this->columns['wcf'.WCF_N.'_user']['registrationIpAddress'] = 'registrationDate'; parent::execute($cronjob); - foreach ($this->columns as $tableName => $columns) { - $columnUpdate = ''; - foreach ($columns as $column) { - if (!empty($columnUpdate)) $columnUpdate .= ','; - $columnUpdate .= "{$column} = ''"; + foreach ($this->columns as $tableName => $columnData) { + foreach ($columnData as $ipAddressColumn => $timestampColumn) { + $sql = "UPDATE {$tableName} + SET {$ipAddressColumn} = ? + WHERE {$timestampColumn} <= ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute([ + '', + TIME_NOW - 86400 * PRUNE_IP_ADDRESS, // 86400 = 1 day + ]); } - - $sql = "UPDATE {$tableName} - SET {$columnUpdate}"; - WCF::getDB() - ->prepareStatement($sql) - ->execute(); } } }