From 7c94866afd417c8ebd0e56d8ecca8b4dde57b5e5 Mon Sep 17 00:00:00 2001 From: Guido Schmechel Date: Sun, 19 Jan 2020 00:58:30 +0100 Subject: [PATCH] [BUGFIX] Task for IP anonymization respects mask IP anonymization now takes the correct pattern when querying the database. Depending on the mask to be shortened. Resolves: #89788 Releases: master, 9.5 Change-Id: Ic09d2385b33434cc2d7553087c2014b190f9c339 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63225 Tested-by: TYPO3com Tested-by: Georg Ringer Reviewed-by: Georg Ringer --- .../sysext/scheduler/Classes/Task/IpAnonymizationTask.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/typo3/sysext/scheduler/Classes/Task/IpAnonymizationTask.php b/typo3/sysext/scheduler/Classes/Task/IpAnonymizationTask.php index fa3e3428d0a9..11d02c6876e3 100644 --- a/typo3/sysext/scheduler/Classes/Task/IpAnonymizationTask.php +++ b/typo3/sysext/scheduler/Classes/Task/IpAnonymizationTask.php @@ -87,6 +87,11 @@ protected function handleTable($table, array $configuration) if ($deleteTimestamp === false) { throw new \RuntimeException(self::class . ' misconfiguration: number of days could not be calculated for table ' . $table, 1524526354); } + if ($this->mask === 2) { + $notLikeMaskPattern = '%.0.0'; + } else { + $notLikeMaskPattern = '%.0'; + } try { $result = $queryBuilder ->select('uid', $configuration['ipField']) @@ -102,7 +107,7 @@ protected function handleTable($table, array $configuration) $queryBuilder->expr()->isNotNull($configuration['ipField']), $queryBuilder->expr()->notLike( $configuration['ipField'], - $queryBuilder->createNamedParameter('%.0.0', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter($notLikeMaskPattern, \PDO::PARAM_STR) ), $queryBuilder->expr()->notLike( $configuration['ipField'],