WCF::getDB()->beginTransaction();
foreach ($objectIDs as $objectID) {
- $statement->executeUnbuffered(array($objectID));
+ $statement->execute(array($objectID));
}
WCF::getDB()->commitTransaction();
$statement = $this->dbObj->prepareStatement($sql);
$statement->execute();
while ($row = $statement->fetchArray()) {
- $typeMatches = Regex::compile('([a-z]+)\(([0-9]+)\)', Regex::CASE_INSENSITIVE)->match($row['Type']);
-
- $columns[] = array('name' => $row['Field'],
- 'data' => array(
- 'type' => $typeMatches[1],
- 'length' => $typeMatches[2],
- 'notNull' => (($row['Null'] == 'YES') ? true : false),
- 'key' => (($row['Key'] == 'PRI') ? 'PRIMARY' : (($row['Key'] == 'UNI') ? 'UNIQUE' : '')),
- 'default' => $row['Default'],
- 'autoIncrement' => ($row['Extra'] == 'auto_increment' ? true : false)
- )
- );
+ $typeMatches = Regex::compile('([a-z]+)\(([0-9]+)\)', Regex::CASE_INSENSITIVE)->match($row['Type']);
+
+ $columns[] = array('name' => $row['Field'],
+ 'data' => array(
+ 'type' => $typeMatches[1],
+ 'length' => $typeMatches[2],
+ 'notNull' => (($row['Null'] == 'YES') ? true : false),
+ 'key' => (($row['Key'] == 'PRI') ? 'PRIMARY' : (($row['Key'] == 'UNI') ? 'UNIQUE' : '')),
+ 'default' => $row['Default'],
+ 'autoIncrement' => ($row['Extra'] == 'auto_increment' ? true : false)
+ )
+ );
}
return $columns;
}
use wcf\system\form\FormDocument;
use wcf\system\form;
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\WCF;
$plugin = new $className($this, $nodeData);
- if (!($plugin instanceof \wcf\system\package\plugin\IPackageInstallationPlugin)) {
+ if (!($plugin instanceof IPackageInstallationPlugin)) {
throw new SystemException("'".$className."' does not implement 'wcf\system\package\plugin\IPackageInstallationPlugin'");
}
- if ($plugin instanceof \wcf\system\package\plugin\SQLPackageInstallationPlugin || $plugin instanceof \wcf\system\package\plugin\ObjectTypePackageInstallationPlugin) {
+ if ($plugin instanceof SQLPackageInstallationPlugin || $plugin instanceof ObjectTypePackageInstallationPlugin) {
$this->requireRestructureVersionTables = true;
}
return;
}
- //base structure of version tables
+ // base structure of version tables
$versionTableBaseColumns = array();
$versionTableBaseColumns[] = array('name' => 'versionID', 'data' => array('type' => 'INT', 'key' => 'PRIMARY', 'autoIncrement' => 'AUTO_INCREMENT'));
$versionTableBaseColumns[] = array('name' => 'versionUserID', 'data' => array('type' => 'INT'));
$versionTableBaseColumns[] = array('name' => 'versionTime', 'data' => array('type' => 'INT'));
foreach ($objectTypes as $objectTypeID => $objectType) {
- //get structure of base table
+ // get structure of base table
$baseTableColumns = WCF::getDB()->getEditor()->getColumns($objectType::getDatabaseTableName());
- //get structure of version table
+ // get structure of version table
$versionTableColumns = WCF::getDB()->getEditor()->getColumns($objectType::getDatabaseVersionTableName());
if (empty($versionTableColumns)){
WCF::getDB()->getEditor()->createTable($objectType::getDatabaseVersionTableName(), $columns);
}
else {
- //check garbage columns in versioned table
+ // check garbage columns in versioned table
foreach ($versionTableColumns as $columnData) {
if (!array_search($columnData['name'], $baseTableColumns, true)) {
- //delete column
+ // delete column
WCF::getDB()->getEditor()->dropColumn($objectType::getDatabaseVersionTableName(), $columnData['name']);
}
}
- //check new columns for versioned table
+ // check new columns for versioned table
foreach ($baseTableColumns as $columnData) {
if (!array_search($columnData['name'], $versionTableColumns, true)) {
- //add colum
+ // add colum
WCF::getDB()->getEditor()->addColumn($objectType::getDatabaseVersionTableName(), $columnData['name'], $columnData['data']);
}
}
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\WCF;
/**
* @see wcf\system\package\PackageInstallationDispatcher::executePIP()
*/
- protected function executePIP(array $nodeData) {
+ protected function executePIP(array $nodeData) {
$pip = new $nodeData['className']($this);
- if ($pip instanceof \wcf\system\package\plugin\SQLPackageInstallationPlugin || $pip instanceof \wcf\system\package\plugin\ObjectTypePackageInstallationPlugin) {
+ if ($pip instanceof SQLPackageInstallationPlugin || $pip instanceof ObjectTypePackageInstallationPlugin) {
$this->requireRestructureVersionTables = true;
}
use wcf\system\cache\CacheHandler;
/**
-* Handles versions of DatabaseObjects.
-*
-* @author Jeffrey Reichardt
-* @copyright 2001-2012 WoltLab GmbH
-* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
-* @package com.woltlab.wcf
-* @subpackage system.version
-* @category Community Framework
-*/
+ * Handles versions of DatabaseObjects.
+ *
+ * @author Jeffrey Reichardt
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.version
+ * @category Community Framework
+ */
class VersionHandler extends SingletonFactory {
/**
- * cached categories
- * @var array<wcf\data\VersionableDatabaseObject>
- */
+ * 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<array>
- */
+ * maps each version id to its object type id and object type version id
+ * @var array<array>
+ */
protected $versionIDs = array();
/**
- * mapes the names of the version object types to the object type ids
- * @var array<integer>
- */
+ * mapes the names of the version object types to the object type ids
+ *
+ * @var array<integer>
+ */
protected $objectTypeIDs = array();
/**
- * list of version object types
- * @var array<wcf\data\object\type>
- */
+ * 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>
- */
+ * 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];
}
/**
- * Returns the category object with the given category id.
- *
- * @param integer $objectTypeID
- * @param integer $versionID
- *
- * @return wcf\data\VersionableDatabaseObject
- */
+ * 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];
}
/**
- * Gets the object type with the given id.
- *
- * @param integer $objectTypeID
- *
- * @return wcf\data\object\type\ObjectType
- */
+ * Gets 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]);
}
/**
- * Gets the object type with the given name.
- *
- * @param string $objectTypeName
- *
- * @return wcf\data\object\type\ObjectType
- */
+ * Gets 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];
}
/**
- * @see wcf\system\SingletonFactory::init()
- */
+ * @see wcf\system\SingletonFactory::init()
+ */
protected function init() {
$this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.versionableObject');
}
/**
- * Reloads the version cache.
- */
+ * Reloads the version cache.
+ */
public function reloadCache() {
CacheHandler::getInstance()->clearResource('version');