<?php
namespace wcf\data\application;
use wcf\data\AbstractDatabaseObjectAction;
+use wcf\data\package\Package;
use wcf\data\package\PackageCache;
use wcf\system\cache\CacheHandler;
use wcf\system\WCF;
}
WCF::getDB()->commitTransaction();
- $this->clearCache();
+ $this->rebuild();
}
/**
if (empty($this->objects)) {
$this->readObjects();
}
- $this->clearCache();
+
$sql = "UPDATE wcf".WCF_N."_application
SET groupID = ?,
cookieDomain = domainName,
}
WCF::getDB()->commitTransaction();
- $this->clearCache();
+ $this->rebuild();
}
/**
- * Clears application cache.
+ * Rebuilds application cache and dependencies.
*/
- protected function clearCache() {
+ protected function rebuild() {
foreach ($this->objects as $application) {
+ // reset cache
$directory = PackageCache::getInstance()->getPackage($application->packageID)->packageDir;
$directory = FileUtil::getRealPath(WCF_DIR.$directory);
CacheHandler::getInstance()->clear($directory.'cache', '*.php');
+
+ // rebuild dependencies
+ Package::rebuildPackageDependencies($application->packageID);
}
}
}
<?php
namespace wcf\data\package;
use wcf\data\DatabaseObject;
+use wcf\system\database\statement\PreparedStatement;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\SystemException;
use wcf\system\io\File;
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
- $insertedDependencies = array();
+ $insertedDependencies = self::insertApplicationDependencies($packageID, $statement);
+ $shiftPriority = (empty($insertedDependencies)) ? false : true;
foreach ($requirements as $dependency => $priority) {
- $statement->execute(array($packageID, $dependency, $priority));
+ $statement->execute(array(
+ $packageID,
+ $dependency,
+ ($shiftPriority ? ($priority + 1) : $priority)
+ ));
if (!isset($insertedDependencies[$packageID])) {
$insertedDependencies[$packageID] = array();
}
}
+ /**
+ * Inserts dependencies on applications within the same application group.
+ *
+ * @param integer $packageID
+ * @param wcf\system\database\statement\PreparedStatement $insertStatement
+ * @return array<string>
+ */
+ protected static function insertApplicationDependencies($packageID, PreparedStatement $insertStatement) {
+ $insertedDependencies = array();
+
+ // check for application group
+ $sql = "SELECT groupID
+ FROM wcf".WCF_N."_application
+ WHERE packageID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($packageID));
+ $row = $statement->fetchArray();
+ if ($row !== false && $row['groupID'] !== null) {
+ // select application ids
+ $sql = "SELECT packageID
+ FROM wcf".WCF_N."_application
+ WHERE groupID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($row['groupID']));
+ while ($row = $statement->fetchArray()) {
+ $insertStatement->execute(array(
+ $packageID,
+ $row['packageID'],
+ 1
+ ));
+ }
+ }
+ }
+
/**
* Writes the config.inc.php for an application.
*