From: Matthias Schmidt Date: Thu, 8 Mar 2012 14:33:07 +0000 (+0100) Subject: Fixes a bug for application with no lang vars X-Git-Tag: 2.0.0_Beta_1~1245^2~2^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5475a95de9653da056df3375b2ff8087b66a1940;p=GitHub%2FWoltLab%2FWCF.git Fixes a bug for application with no lang vars This bug should also occur if the active application supports less languages than installed and the installed package supports languages that are installed but not supported by the active application. In those cases, the localized package infos weren't saved since the language array way empty (or not all localizations were saved). Now all languages are fetched and now this also happens at the very end of the installation which makes it possible to save the localized data in a new language that was delivered by the installed package (though this seems to be not supported yet). --- diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index eb2c7bc2b9..464fef37a1 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -130,9 +130,11 @@ class PackageInstallationDispatcher { $node = $this->nodeBuilder->getNextNode($node); $step->setNode($node); - // update options.inc.php if installation is completed + // update options.inc.php and save localized package infos if ($node == '') { OptionEditor::resetCache(); + + $this->saveLocalizedPackageInfos(); } return $step; @@ -211,39 +213,6 @@ class PackageInstallationDispatcher { // create package entry $package = PackageEditor::create($nodeData); - // localize package information - $sql = "INSERT INTO wcf".WCF_N."_language_item - (languageID, languageItem, languageItemValue, languageCategoryID, packageID) - VALUES (?, ?, ?, ?, ?)"; - $statement = WCF::getDB()->prepareStatement($sql); - - // workaround for WCFSetup - if (!PACKAGE_ID) { - $sql = "SELECT * - FROM wcf".WCF_N."_language_category - WHERE languageCategory = ?"; - $statement2 = WCF::getDB()->prepareStatement($sql); - $statement2->execute(array('wcf.acp.package')); - $languageCategory = $statement2->fetchObject('wcf\data\language\category\LanguageCategory'); - } - else { - $languageCategory = LanguageFactory::getInstance()->getCategory('wcf.acp.package'); - } - - // save package name - $this->saveLocalizedPackageInfo($statement, $languageCategory, $package, 'packageName'); - - // save package description - $this->saveLocalizedPackageInfo($statement, $languageCategory, $package, 'packageDescription'); - - // todo: license and readme - - $packageEditor = new PackageEditor($package); - $packageEditor->update(array( - 'packageDescription' => 'wcf.acp.package.packageDescription.package'.$package->packageID, - 'packageName' => 'wcf.acp.package.packageName.package'.$package->packageID - )); - // update package id for current queue $queueEditor = new PackageInstallationQueueEditor($this->queue); $queueEditor->update(array( @@ -329,15 +298,62 @@ class PackageInstallationDispatcher { return $installationStep; } + /** + * Saves the localized package infos. + * + * @todo license and readme + */ + protected function saveLocalizedPackageInfos() { + $package = new Package($this->queue->packageID); + + // localize package information + $sql = "INSERT INTO wcf".WCF_N."_language_item + (languageID, languageItem, languageItemValue, languageCategoryID, packageID) + VALUES (?, ?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + + // get language list + $languageList = new LanguageList(); + $languageList->sqlLimit = 0; + $languageList->readObjects(); + + // workaround for WCFSetup + if (!PACKAGE_ID) { + $sql = "SELECT * + FROM wcf".WCF_N."_language_category + WHERE languageCategory = ?"; + $statement2 = WCF::getDB()->prepareStatement($sql); + $statement2->execute(array('wcf.acp.package')); + $languageCategory = $statement2->fetchObject('wcf\data\language\category\LanguageCategory'); + } + else { + $languageCategory = LanguageFactory::getInstance()->getCategory('wcf.acp.package'); + } + + // save package name + $this->saveLocalizedPackageInfo($statement, $languageList, $languageCategory, $package, 'packageName'); + + // save package description + $this->saveLocalizedPackageInfo($statement, $languageList, $languageCategory, $package, 'packageDescription'); + + // update description and name + $packageEditor = new PackageEditor($package); + $packageEditor->update(array( + 'packageDescription' => 'wcf.acp.package.packageDescription.package'.$this->queue->packageID, + 'packageName' => 'wcf.acp.package.packageName.package'.$this->queue->packageID + )); + } + /** * Saves a localized package info. * * @param wcf\system\database\statement\PreparedStatement $statement + * @param wcf\data\language\LanguageList $languageList * @param wcf\data\language\category\LanguageCategory $languageCategory * @param wcf\data\package\Package $package * @param string $infoName */ - protected function saveLocalizedPackageInfo(PreparedStatement $statement, LanguageCategory $languageCategory, Package $package, $infoName) { + protected function saveLocalizedPackageInfo(PreparedStatement $statement, $languageList, LanguageCategory $languageCategory, Package $package, $infoName) { $infoValues = $this->getArchive()->getPackageInfo($infoName); // get default value for languages without specified information @@ -358,18 +374,7 @@ class PackageInstallationDispatcher { $defaultValue = $this->archive->getPackageInfo('name'); } - // workaround for WCFSetup - if (!PACKAGE_ID) { - $languageList = new LanguageList(); - $languageList->sqlLimit = 0; - $languageList->readObjects(); - $languages = $languageList->getObjects(); - } - else { - $languages = LanguageFactory::getInstance()->getLanguages(); - } - - foreach ($languages as $language) { + foreach ($languageList as $language) { $value = $defaultValue; if (isset($infoValues[$language->languageCode])) { $value = $infoValues[$language->languageCode];