From a89ab1feb761d760804e89773851a00595520374 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 24 May 2015 15:38:53 +0200 Subject: [PATCH] Remove version system --- CHANGELOG.md | 3 +- com.woltlab.wcf/objectTypeDefinition.xml | 4 - .../data/VersionableDatabaseObject.class.php | 57 -------- .../VersionableDatabaseObjectAction.class.php | 108 -------------- .../VersionableDatabaseObjectEditor.class.php | 87 ------------ .../builder/VersionCacheBuilder.class.php | 51 ------- .../PackageInstallationDispatcher.class.php | 103 -------------- .../PackageUninstallationDispatcher.class.php | 10 -- .../system/version/VersionHandler.class.php | 133 ------------------ 9 files changed, 2 insertions(+), 554 deletions(-) delete mode 100644 wcfsetup/install/files/lib/data/VersionableDatabaseObject.class.php delete mode 100644 wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php delete mode 100644 wcfsetup/install/files/lib/data/VersionableDatabaseObjectEditor.class.php delete mode 100644 wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php delete mode 100644 wcfsetup/install/files/lib/system/version/VersionHandler.class.php diff --git a/CHANGELOG.md b/CHANGELOG.md index e932a0c11e..3fb56b9054 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,4 +16,5 @@ * `wcf\system\cache\builder\EventListenerCacheBuilder` returns `wcf\data\event\listener\EventListener` objects instead of data arrays. * `wcf\system\clipboard\action\UserExtendedClipboardAction` removed. * `wcf\system\event\listener\PreParserAtUserListener` removed. -* `wcf\action\AJAXProxyAction::getData()` remove. +* `wcf\action\AJAXProxyAction::getData()` removed. +* Version system removed. diff --git a/com.woltlab.wcf/objectTypeDefinition.xml b/com.woltlab.wcf/objectTypeDefinition.xml index 4f9ddc2ba0..3e7ae5cc8f 100644 --- a/com.woltlab.wcf/objectTypeDefinition.xml +++ b/com.woltlab.wcf/objectTypeDefinition.xml @@ -22,10 +22,6 @@ com.woltlab.wcf.modifiableContent - - com.woltlab.wcf.versionableObject - - com.woltlab.wcf.attachment.objectType diff --git a/wcfsetup/install/files/lib/data/VersionableDatabaseObject.class.php b/wcfsetup/install/files/lib/data/VersionableDatabaseObject.class.php deleted file mode 100644 index 60f1d9c88d..0000000000 --- a/wcfsetup/install/files/lib/data/VersionableDatabaseObject.class.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data - * @category Community Framework - */ -abstract class VersionableDatabaseObject extends DatabaseObject { - /** - * name of the versionable object type - * @var string - */ - public $versionableObjectTypeName = ''; - - /** - * Returns suffix of the version database table. - * - * @return string - */ - public static function getDatabaseVersionTableName() { - return static::getDatabaseTableName().'_version'; - } - - /** - * Returns name of index in version database table. - * - * @return string - */ - public static function getDatabaseVersionTableIndexName() { - return 'versionID'; - } - - /** - * Returns all versions of this database object. - * - * @return array<\wcf\data\VersionableDatabaseObject> - */ - public function getVersions() { - $objectType = VersionHandler::getInstance()->getObjectTypeByName($this->versionableObjectTypeName); - - if ($objectType === null) { - throw new SystemException("Unknown versionable object type with name '".$this->versionableObjectTypeName."'"); - } - - return VersionHandler::getInstance()->getVersions($objectType->objectTypeID, $this->getObjectID()); - } -} diff --git a/wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php deleted file mode 100644 index 5af76876a0..0000000000 --- a/wcfsetup/install/files/lib/data/VersionableDatabaseObjectAction.class.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data - * @category Community Framework - */ -abstract class VersionableDatabaseObjectAction extends AbstractDatabaseObjectAction { - /** - * Validates restoring a version. - */ - public function validateRestoreRevision() { - parent::validateUpdate(); - } - - /** - * @see \wcf\data\IDeleteAction::delete() - */ - public function delete() { - if (empty($this->objects)) { - $this->readObjects(); - } - - // get ids - $objectIDs = array(); - foreach ($this->objects as $object) { - $objectIDs[] = $object->getObjectID(); - } - - // execute action - return call_user_func(array($this->className, 'deleteAll'), $objectIDs); - } - - /** - * @see \wcf\data\AbstractDatabaseObjectAction::update() - */ - public function update() { - if (empty($this->objects)) { - $this->readObjects(); - } - - if (isset($this->parameters['data'])) { - foreach ($this->objects as $object) { - $object->update($this->parameters['data']); - } - - // create revision retroactively - $this->createRevision(); - } - } - - /** - * Creates a new revision. - */ - protected function createRevision() { - $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName')); - - foreach ($this->objects as $object) { - call_user_func(array($this->className, 'createRevision'), array_merge($object->getDecoratedObject()->getData(), array($indexName => $object->getObjectID()))); - } - } - - /** - * Deletes a revision. - */ - protected function deleteRevision() { - if (empty($this->objects)) { - $this->readObjects(); - } - - // get ids - $objectIDs = array(); - foreach ($this->objects as $object) { - $objectIDs[] = $object->getObjectID(); - } - - // execute action - return call_user_func(array($this->className, 'deleteRevision'), $objectIDs); - } - - /** - * Restores a revision. - */ - public function restoreRevision() { - if (empty($this->objects)) { - $this->readObjects(); - } - - // currently we only support restoring one version - foreach ($this->objects as $object) { - $objectType = VersionHandler::getInstance()->getObjectTypeByName($object->versionableObjectTypeName); - $restoreObject = VersionHandler::getInstance()->getVersionByID($objectType->objectTypeID, $this->parameters['restoreObjectID']); - - $this->parameters['data'] = $restoreObject->getData(); - } - - $this->update(); - } -} diff --git a/wcfsetup/install/files/lib/data/VersionableDatabaseObjectEditor.class.php b/wcfsetup/install/files/lib/data/VersionableDatabaseObjectEditor.class.php deleted file mode 100644 index 15fbdc6ac8..0000000000 --- a/wcfsetup/install/files/lib/data/VersionableDatabaseObjectEditor.class.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage data - * @category Community Framework - */ -abstract class VersionableDatabaseObjectEditor extends DatabaseObjectEditor { - /** - * @see \wcf\data\IEditableObject::create() - */ - public static function createRevision(array $parameters = array()) { - $keys = $values = ''; - $statementParameters = array(); - foreach ($parameters as $key => $value) { - if (!empty($keys)) { - $keys .= ','; - $values .= ','; - } - - $keys .= $key; - $values .= '?'; - $statementParameters[] = $value; - } - - // save object - $sql = "INSERT INTO ".static::getDatabaseVersionTableName()." (".$keys.") - VALUES (".$values.")"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($statementParameters); - - // return new object - $id = WCF::getDB()->getInsertID(static::getDatabaseVersionTableName(), static::getDatabaseVersionTableIndexName()); - - return new static::$baseClass($id); - } - - /** - * @see \wcf\data\IEditableObject::delete() - */ - public function deleteRevision(array $objectIDs = array()) { - static::deleteAll(array($this->__get(static::getDatabaseVersionTableIndexName()))); - } - - /** - * @see \wcf\data\IEditableObject::deleteAll() - */ - public static function deleteAll(array $objectIDs = array()) { - $affectedCount = static::deleteAll($objectIDs); - - // delete versions - $sql = "DELETE FROM ".static::getDatabaseVersionTableName()." - WHERE ".static::getDatabaseTableIndexName()." = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - - WCF::getDB()->beginTransaction(); - foreach ($objectIDs as $objectID) { - $statement->execute(array($objectID)); - } - WCF::getDB()->commitTransaction(); - - return $affectedCount; - } - - /** - * @see \wcf\data\VersionableDatabaseObject::getDatabaseVersionTableName() - */ - public static function getDatabaseVersionTableName() { - return call_user_func(array(static::$baseClass, 'getDatabaseVersionTableName')); - } - - /** - * @see \wcf\data\VersionableDatabaseObject::getDatabaseVersionTableIndexName() - */ - public static function getDatabaseVersionTableIndexName() { - return call_user_func(array(static::$baseClass, 'getDatabaseVersionTableIndexName')); - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php deleted file mode 100644 index 530de28595..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/VersionCacheBuilder.class.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class VersionCacheBuilder extends AbstractCacheBuilder { - /** - * @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild() - */ - public function rebuild(array $parameters) { - // get object types - $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.versionableObject'); - - $data = array( - 'versions' => array(), - 'versionIDs' => array() - ); - - foreach ($objectTypes as $objectType) { - $objectTypeID = $objectType->objectTypeID; - - $sql = "SELECT * - FROM ". call_user_func(array($objectType->className, 'getDatabaseVersionTableName')); - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array()); - - while ($row = $statement->fetchArray()) { - $databaseIndexName = call_user_func(array($objectType->className, 'getDatabaseTableIndexName')); - $databaseVersionTableIndexName = call_user_func(array($objectType->className, 'getDatabaseVersionTableIndexName')); - - $object = new $objectType->className(null, $row); - $data['versions'][$objectTypeID][$object->$databaseIndexName][] = $object; - $data['versionIDs'][$objectTypeID][$object->$databaseIndexName][] = $object->$databaseVersionTableIndexName; - } - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 9e83703b1c..497e5b410b 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -25,8 +25,6 @@ use wcf\system\form\element\TextInputFormElement; use wcf\system\form\FormDocument; use wcf\system\language\LanguageFactory; use wcf\system\package\plugin\IPackageInstallationPlugin; -use wcf\system\package\plugin\ObjectTypePackageInstallationPlugin; -use wcf\system\package\plugin\SQLPackageInstallationPlugin; use wcf\system\request\LinkHandler; use wcf\system\request\RouteHandler; use wcf\system\setup\Installer; @@ -84,12 +82,6 @@ class PackageInstallationDispatcher { */ const CONFIG_FILE = 'config.inc.php'; - /** - * holds state of structuring version tables - * @var boolean - */ - protected $requireRestructureVersionTables = false; - /** * data of previous package in queue * @var array @@ -261,10 +253,6 @@ class PackageInstallationDispatcher { $statement->execute(array($this->queue->processNo)); } - if ($this->requireRestructureVersionTables) { - $this->restructureVersionTables(); - } - return $step; } @@ -569,10 +557,6 @@ class PackageInstallationDispatcher { throw new SystemException("'".$className."' does not implement 'wcf\system\package\plugin\IPackageInstallationPlugin'"); } - if ($plugin instanceof SQLPackageInstallationPlugin || $plugin instanceof ObjectTypePackageInstallationPlugin) { - $this->requireRestructureVersionTables = true; - } - // execute PIP $document = null; try { @@ -1105,91 +1089,4 @@ class PackageInstallationDispatcher { break; } } - - /** - * Restructure version tables. - * - * @deprecated 2.1 - will be removed with WCF 2.2 - */ - protected function restructureVersionTables() { - $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.versionableObject'); - - if (empty($objectTypes)) { - return; - } - - // base structure of version tables - $versionTableBaseColumns = array(); - $versionTableBaseColumns[] = array('name' => 'versionID', 'data' => array('type' => 'INT', 'length' => 10, 'key' => 'PRIMARY', 'autoIncrement' => 'AUTO_INCREMENT')); - $versionTableBaseColumns[] = array('name' => 'versionUserID', 'data' => array('type' => 'INT', 'length' => 10)); - $versionTableBaseColumns[] = array('name' => 'versionUsername', 'data' => array('type' => 'VARCHAR', 'length' => 255)); - $versionTableBaseColumns[] = array('name' => 'versionTime', 'data' => array('type' => 'INT', 'length' => 10)); - - foreach ($objectTypes as $objectType) { - if (!class_exists($objectType->className)) { - // versionable database object isn't available anymore - // the object type gets deleted later on during the uninstallation - continue; - } - $baseTableColumns = WCF::getDB()->getEditor()->getColumns(call_user_func(array($objectType->className, 'getDatabaseTableName'))); - - // remove primary key from base table columns - foreach ($baseTableColumns as $key => $column) { - if ($column['data']['key'] == 'PRIMARY') { - $baseTableColumns[$key]['data']['key'] = ''; - } - $baseTableColumns[$key]['data']['autoIncrement'] = false; - } - - // get structure of version table - $versionTableColumns = array(); - try { - $versionTableColumns = WCF::getDB()->getEditor()->getColumns(call_user_func(array($objectType->className, 'getDatabaseVersionTableName'))); - } - catch (\Exception $e) { } - - if (empty($versionTableColumns)) { - $columns = array_merge($versionTableBaseColumns, $baseTableColumns); - WCF::getDB()->getEditor()->createTable(call_user_func(array($objectType->className, 'getDatabaseVersionTableName')), $columns); - - // add version table to plugin - $sql = "INSERT INTO wcf".WCF_N."_package_installation_sql_log - (packageID, sqlTable) - VALUES (?, ?)"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - $this->queue->packageID, - call_user_func(array($objectType->className, 'getDatabaseVersionTableName')) - )); - } - else { - $baseTableColumnNames = $versionTableColumnNames = $versionTableBaseColumnNames = array(); - foreach ($baseTableColumns as $column) { - $baseTableColumnNames[] = $column['name']; - } - foreach ($versionTableColumns as $column) { - $versionTableColumnNames[] = $column['name']; - } - foreach ($versionTableBaseColumns as $column) { - $versionTableBaseColumnNames[] = $column['name']; - } - - // check garbage columns in versioned table - foreach ($versionTableColumns as $columnData) { - if (!in_array($columnData['name'], $baseTableColumnNames) && !in_array($columnData['name'], $versionTableBaseColumnNames)) { - // delete column - WCF::getDB()->getEditor()->dropColumn(call_user_func(array($objectType->className, 'getDatabaseVersionTableName')), $columnData['name']); - } - } - - // check new columns for versioned table - foreach ($baseTableColumns as $columnData) { - if (!in_array($columnData['name'], $versionTableColumnNames)) { - // add colum - WCF::getDB()->getEditor()->addColumn(call_user_func(array($objectType->className, 'getDatabaseVersionTableName')), $columnData['name'], $columnData['data']); - } - } - } - } - } } diff --git a/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php index ee8f84cef1..abd508403c 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUninstallationDispatcher.class.php @@ -11,8 +11,6 @@ use wcf\system\event\EventHandler; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\SystemException; use wcf\system\language\LanguageFactory; -use wcf\system\package\plugin\ObjectTypePackageInstallationPlugin; -use wcf\system\package\plugin\SQLPackageInstallationPlugin; use wcf\system\setup\Uninstaller; use wcf\system\style\StyleHandler; use wcf\system\user\storage\UserStorageHandler; @@ -93,10 +91,6 @@ class PackageUninstallationDispatcher extends PackageInstallationDispatcher { EventHandler::getInstance()->fireAction($this, 'postUninstall'); } - if ($this->requireRestructureVersionTables) { - $this->restructureVersionTables(); - } - // return next node return $node; } @@ -107,10 +101,6 @@ class PackageUninstallationDispatcher extends PackageInstallationDispatcher { protected function executePIP(array $nodeData) { $pip = new $nodeData['className']($this); - if ($pip instanceof SQLPackageInstallationPlugin || $pip instanceof ObjectTypePackageInstallationPlugin) { - $this->requireRestructureVersionTables = true; - } - $pip->uninstall(); } diff --git a/wcfsetup/install/files/lib/system/version/VersionHandler.class.php b/wcfsetup/install/files/lib/system/version/VersionHandler.class.php deleted file mode 100644 index 6585a8ca81..0000000000 --- a/wcfsetup/install/files/lib/system/version/VersionHandler.class.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.version - * @category Community Framework - */ -class VersionHandler extends SingletonFactory { - /** - * cached versions - * @var array<\wcf\data\VersionableDatabaseObject> - */ - protected $versions = array(); - - /** - * maps each version id to its object type id and object type version id - * @var array - */ - protected $versionIDs = array(); - - /** - * mapes the names of the version object types to the object type ids - * @var array - */ - protected $objectTypeIDs = array(); - - /** - * list of version object types - * @var array<\wcf\data\object\type> - */ - protected $objectTypes = array(); - - /** - * Returns all version of object with the given object type id and object id. - * - * @param integer $objectTypeID - * @param integer $objectID - * @return array<\wcf\data\VersionableDatabaseObject> - */ - public function getVersions($objectTypeID, $objectID) { - if (isset($this->versions[$objectTypeID][$objectID])) { - return $this->versions[$objectTypeID][$objectID]; - } - - return array(); - } - - /** - * Returns the database object with the given version id. - * - * @param integer $objectTypeID - * @param integer $versionID - * @return \wcf\data\VersionableDatabaseObject - */ - public function getVersionByID($objectTypeID, $versionID) { - if (isset($this->versionIDs[$objectTypeID][$versionID])) { - return $this->versionIDs[$objectTypeID][$versionID]; - } - - return null; - } - - /** - * Returns the object type with the given id. - * - * @param integer $objectTypeID - * @return \wcf\data\object\type\ObjectType - */ - public function getObjectType($objectTypeID) { - if (isset($this->objectTypeIDs[$objectTypeID])) { - return $this->getObjectTypeByName($this->objectTypeIDs[$objectTypeID]); - } - - return null; - } - - /** - * Returns the object type with the given name. - * - * @param string $objectTypeName - * @return \wcf\data\object\type\ObjectType - */ - public function getObjectTypeByName($objectTypeName) { - if (isset($this->objectTypes[$objectTypeName])) { - return $this->objectTypes[$objectTypeName]; - } - - return null; - } - - /** - * @see \wcf\system\SingletonFactory::init() - */ - protected function init() { - $this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.versionableObject'); - - foreach ($this->objectTypes as $objectType) { - $this->objectTypeIDs[$objectType->objectTypeID] = $objectType->objectType; - } - - $this->versions = VersionCacheBuilder::getInstance()->getData(array(), 'versions'); - $this->versionIDs = VersionCacheBuilder::getInstance()->getData(array(), 'versionIDs'); - } - - /** - * Reloads the version cache. - */ - public function reloadCache() { - VersionCacheBuilder::getInstance()->reset(); - - $this->init(); - } - - /** - * Returns a list of object types - * - * @return array<\wcf\data\object\type\ObjectType> - */ - public function getObjectTypes() { - return $this->objectTypes; - } -} -- 2.20.1