From: Alexander Ebert Date: Wed, 5 Dec 2012 00:47:33 +0000 (+0100) Subject: Fixed application management during setup X-Git-Tag: 2.0.0_Beta_1~741^2~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=131de12381ad38efa5e5ae4144aa43783ad8edb1;p=GitHub%2FWoltLab%2FWCF.git Fixed application management during setup --- diff --git a/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php b/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php index 81dbf456ab..ad7573785f 100644 --- a/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php +++ b/wcfsetup/install/files/lib/data/application/ApplicationAction.class.php @@ -33,8 +33,7 @@ class ApplicationAction extends AbstractDatabaseObjectAction { $sql = "UPDATE wcf".WCF_N."_application SET cookieDomain = ?, - cookiePath = ?, - isPrimary = ? + cookiePath = ? WHERE packageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); @@ -80,7 +79,6 @@ class ApplicationAction extends AbstractDatabaseObjectAction { $statement->execute(array( $domainName, $path, - $isPrimary, $packageID )); } diff --git a/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php b/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php index f7825e5741..696a95703c 100644 --- a/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php +++ b/wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php @@ -1,6 +1,9 @@ prepareStatement($sql); + $statement->execute(array(0)); + + $sql = "UPDATE wcf".WCF_N."_application + SET isPrimary = ? + WHERE applicationID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + 1, + $this->applicationID + )); + + self::resetCache(); + } + + /** + * Sets the first installed application as primary unless an other application already is primary. + */ + public static function setup() { + $sql = "SELECT COUNT(*) AS count + FROM wcf".WCF_N."_application + WHERE isApplication = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array(1)); + $row = $statement->fetchArray(); + + if ($row['count']) { + // there is already a primary application + return; + } + else { + // set first installed application as primary + $sql = "SELECT packageID + FROM wcf".WCF_N."_package + WHERE packageID <> ? + AND isApplication = ? + ORDER BY installDate ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + 1, + 1 + )); + $row = $statement->fetchArray(); + + $sql = "UPDATE wcf".WCF_N."_application + SET isApplication = ? + WHERE packageID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($row['packageID'])); + } + } + + /** + * @see wcf\data\IEditableCachedObject::resetCache() + */ + public static function resetCache() { + CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.application.php'); + } } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 7b9c25477c..30bdd90fc5 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -145,6 +145,7 @@ class PackageInstallationDispatcher { // rebuild application paths ApplicationHandler::rebuild(); + ApplicationEditor::setup(); } }