From ad832e7d32cad9478e24d4346d95f45783717b9e Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 24 Jun 2021 08:08:46 +0200 Subject: [PATCH] Delete `ModificationLogHandler` (#4340) This class has been deprecated for many years since 28854f57445a35894483db28e250f94b444962a0. --- com.woltlab.wcf/fileDelete.xml | 1 + .../ModificationLogHandler.class.php | 142 ------------------ 2 files changed, 1 insertion(+), 142 deletions(-) delete mode 100644 wcfsetup/install/files/lib/system/log/modification/ModificationLogHandler.class.php diff --git a/com.woltlab.wcf/fileDelete.xml b/com.woltlab.wcf/fileDelete.xml index db4e9a727f..ab51b500d0 100644 --- a/com.woltlab.wcf/fileDelete.xml +++ b/com.woltlab.wcf/fileDelete.xml @@ -1831,6 +1831,7 @@ lib/system/html/output/node/HtmlOutputNodeWoltlabSize.class.php lib/system/image/Thumbnail.class.php lib/system/language/LanguageServerProcessor.class.php + lib/system/log/modification/ModificationLogHandler.class.php lib/system/mail/DebugMailSender.class.php lib/system/mail/MailSender.class.php lib/system/mail/PHPMailSender.class.php diff --git a/wcfsetup/install/files/lib/system/log/modification/ModificationLogHandler.class.php b/wcfsetup/install/files/lib/system/log/modification/ModificationLogHandler.class.php deleted file mode 100644 index a173cbf3be..0000000000 --- a/wcfsetup/install/files/lib/system/log/modification/ModificationLogHandler.class.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @package WoltLabSuite\Core\System\Log\Modification - * @deprecated 3.0, use AbstractModificationLogHandler - */ -class ModificationLogHandler extends SingletonFactory -{ - /** - * list of object types - * @var ObjectType[] - */ - protected $cache = []; - - /** - * @inheritDoc - */ - protected function init() - { - $this->cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.modifiableContent'); - } - - /** - * Returns object type by object type name. - * - * @param string $objectType - * @return ObjectType|null - */ - public function getObjectType($objectType) - { - foreach ($this->cache as $objectTypeObj) { - if ($objectTypeObj->objectType == $objectType) { - return $objectTypeObj; - } - } - - return null; - } - - /** - * Adds a new entry to modification log. - * - * @param string $objectType - * @param int $objectID - * @param string $action - * @param array $additionalData - * @param int $time - * @param int $userID - * @param string $username - * @return ModificationLog - * @throws SystemException - */ - // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore - protected function _add( - $objectType, - $objectID, - $action, - array $additionalData = [], - $time = TIME_NOW, - $userID = null, - $username = null - ) { - $objectTypeObj = $this->getObjectType($objectType); - if ($objectTypeObj === null) { - throw new SystemException( - "Object type '" . $objectType . "' not found within definition 'com.woltlab.wcf.modifiableContent'" - ); - } - - if ($userID === null) { - if (WCF::getUser()->userID) { - $userID = WCF::getUser()->userID; - } elseif ($username === null) { - $username = 'System'; - } - } - if ($username === null) { - if (WCF::getUser()->username) { - $username = WCF::getUser()->username; - } else { - $username = ''; - } - } - - $action = new ModificationLogAction([], 'create', [ - 'data' => [ - 'objectTypeID' => $objectTypeObj->objectTypeID, - 'objectID' => $objectID, - 'action' => $action, - 'userID' => $userID, - 'username' => $username, - 'time' => $time, - 'additionalData' => \serialize($additionalData), - ], - ]); - - return $action->executeAction()['returnValues']; - } - - /** - * Removes log entries. - * - * @param string $objectType - * @param int[] $objectIDs - * @throws SystemException - */ - // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore - protected function _remove($objectType, array $objectIDs) - { - $objectTypeObj = $this->getObjectType($objectType); - if ($objectTypeObj === null) { - throw new SystemException( - "Object type '" . $objectType . "' not found within definition 'com.woltlab.wcf.modifiableContent'" - ); - } - - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("objectTypeID = ?", [$objectTypeObj->objectTypeID]); - $conditions->add("objectID IN (?)", [$objectIDs]); - - $sql = "DELETE FROM wcf" . WCF_N . "_modification_log - " . $conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - } -} -- 2.20.1