Installation is now working, but still things are broken
authorAlexander Ebert <ebert@woltlab.com>
Wed, 5 Dec 2012 01:52:23 +0000 (02:52 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 5 Dec 2012 01:52:23 +0000 (02:52 +0100)
Fixes #960

wcfsetup/install/files/lib/data/application/ApplicationEditor.class.php
wcfsetup/install/files/lib/data/language/Language.class.php
wcfsetup/install/files/lib/data/language/LanguageEditor.class.php
wcfsetup/install/files/lib/data/package/Package.class.php
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php
wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php
wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php

index 696a95703ce8b0bfd05653b7636107e28ae7659a..f67913e6800b0b0dc48126c0f22b75c14dab597d 100644 (file)
@@ -32,7 +32,7 @@ class ApplicationEditor extends DatabaseObjectEditor implements IEditableCachedO
                
                $sql = "UPDATE  wcf".WCF_N."_application
                        SET     isPrimary = ?
-                       WHERE   applicationID = ?";
+                       WHERE   packageID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array(
                        1,
index b1811afadc85143d28272d655b20df20158af079..a8d94e32514eb5642211bd32ced85e5919d23040 100644 (file)
@@ -139,7 +139,7 @@ class Language extends DatabaseObject {
                }
                
                // search language file
-               $filename = WCF_DIR.'language/'.$this->packageID.'_'.$this->languageID.'_'.$category.'.php';
+               $filename = WCF_DIR.'language/'.$this->languageID.'_'.$category.'.php';
                if (!@file_exists($filename)) { 
                        if ($this->editor === null) {
                                $this->editor = new LanguageEditor($this);
@@ -147,7 +147,7 @@ class Language extends DatabaseObject {
                        
                        // rebuild language file
                        $languageCategory = LanguageFactory::getInstance()->getCategory($category);
-                       $this->editor->updateCategory(array($languageCategory->languageCategoryID), array($this->packageID));
+                       $this->editor->updateCategory(array($languageCategory->languageCategoryID));
                }
                
                // include language file
index c2316430c1a7a1f7c4d26d06101587570fe314cb..8c12b75ea9c5181da647af40a3a48b2e38232cf5 100644 (file)
@@ -45,10 +45,9 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje
        /**
         * Updates the language files for the given category.
         *
-        * @param       array           $categoryIDs
-        * @param       array           $packageIDs
+        * @param       array<integer>          $categoryIDs
         */
-       public function updateCategory(array $categoryIDs = array(), array $packageIDs = array()) {
+       public function updateCategory(array $categoryIDs = array()) {
                if (empty($categoryIDs)) {
                        // get all categories
                        $sql = "SELECT  languageCategoryID
@@ -60,16 +59,15 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje
                        }
                }
                
-               $this->writeLanguageFiles($categoryIDs, $packageIDs);
+               $this->writeLanguageFiles($categoryIDs);
        }
        
        /**
         * Write the languages files.
         *
         * @param       array           $categoryIDs
-        * @param       array           $packageIDs
         */
-       protected function writeLanguageFiles(array $categoryIDs, array $packageIDs) {
+       protected function writeLanguageFiles(array $categoryIDs) {
                // get categories
                $conditions = new PreparedStatementConditionBuilder();
                $conditions->add("languageCategoryID IN (?)", array($categoryIDs));
@@ -83,48 +81,44 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje
                        $categoryName = $category['languageCategory'];
                        $categoryID = $category['languageCategoryID'];
                        
-                       // loop packages
-                       foreach ($packageIDs as $packageID) {
-                               $conditions = new PreparedStatementConditionBuilder();
-                               $conditions->add("languageID = ?", array($this->languageID));
-                               $conditions->add("languageCategoryID = ?", array($categoryID));
-                               
-                               // get language items
-                               $conditions->add("packageID IS NULL");
-                               $sql = "SELECT  languageItem, languageItemValue, languageCustomItemValue, languageUseCustomValue
-                                       FROM    wcf".WCF_N."_language_item
-                                       ".$conditions;
-                               
-                               $statement2 = WCF::getDB()->prepareStatement($sql);
-                               $statement2->execute($conditions->getParameters());
-                               $items = array();
-                               while ($row = $statement2->fetchArray()) {
-                                       if ($row['languageUseCustomValue'] == 1) {
-                                               $items[$row['languageItem']] = $row['languageCustomItemValue'];
-                                       }
-                                       else {
-                                               $items[$row['languageItem']] = $row['languageItemValue'];
-                                       }
+                       $conditions = new PreparedStatementConditionBuilder();
+                       $conditions->add("languageID = ?", array($this->languageID));
+                       $conditions->add("languageCategoryID = ?", array($categoryID));
+                       
+                       // get language items
+                       $sql = "SELECT  languageItem, languageItemValue, languageCustomItemValue, languageUseCustomValue
+                               FROM    wcf".WCF_N."_language_item
+                               ".$conditions;
+                       
+                       $statement2 = WCF::getDB()->prepareStatement($sql);
+                       $statement2->execute($conditions->getParameters());
+                       $items = array();
+                       while ($row = $statement2->fetchArray()) {
+                               if ($row['languageUseCustomValue'] == 1) {
+                                       $items[$row['languageItem']] = $row['languageCustomItemValue'];
                                }
+                               else {
+                                       $items[$row['languageItem']] = $row['languageItemValue'];
+                               }
+                       }
+                       
+                       if (!empty($items)) {
+                               $content = "<?php\n/**\n* WoltLab Community Framework\n* language: ".$this->languageCode."\n* encoding: UTF-8\n* category: ".$categoryName."\n* generated at ".gmdate("r")."\n* \n* DO NOT EDIT THIS FILE\n*/\n";
                                
-                               if (!empty($items)) {
-                                       $content = "<?php\n/**\n* WoltLab Community Framework\n* language: ".$this->languageCode."\n* encoding: UTF-8\n* category: ".$categoryName."\n* generated at ".gmdate("r")."\n* \n* DO NOT EDIT THIS FILE\n*/\n";
+                               foreach ($items as $languageItem => $languageItemValue) {
+                                       $content .= "\$this->items['".$languageItem."'] = '".str_replace("'", "\'", $languageItemValue)."';\n";
                                        
-                                       foreach ($items as $languageItem => $languageItemValue) {
-                                               $content .= "\$this->items['".$languageItem."'] = '".str_replace("'", "\'", $languageItemValue)."';\n";
-                                               
-                                               // compile dynamic language variables
-                                               if ($categoryName != 'wcf.global' && strpos($languageItemValue, '{') !== false) {
-                                                       $output = LanguageFactory::getInstance()->getScriptingCompiler()->compileString($languageItem, $languageItemValue);
-                                                       $content .= "\$this->dynamicItems['".$languageItem."'] = '".str_replace("'", "\'", $output['template'])."';\n";
-                                               }
+                                       // compile dynamic language variables
+                                       if ($categoryName != 'wcf.global' && strpos($languageItemValue, '{') !== false) {
+                                               $output = LanguageFactory::getInstance()->getScriptingCompiler()->compileString($languageItem, $languageItemValue);
+                                               $content .= "\$this->dynamicItems['".$languageItem."'] = '".str_replace("'", "\'", $output['template'])."';\n";
                                        }
-                                       
-                                       $file = new File(WCF_DIR.'language/'.$packageID.'_'.$this->languageID.'_'.$categoryName.'.php');
-                                       @$file->chmod(0777);
-                                       $file->write($content . '?>');
-                                       $file->close();
                                }
+                               
+                               $file = new File(WCF_DIR.'language/'.$this->languageID.'_'.$categoryName.'.php');
+                               @$file->chmod(0777);
+                               $file->write($content . '?>');
+                               $file->close();
                        }
                }
        }
index 31baa4df1e74733fffe16b3cbd5b7f7705fa4be0..1db6dbb941beb16012b86d43601a25cccbaa39b5 100644 (file)
@@ -368,7 +368,7 @@ class Package extends DatabaseObject {
                // write general information
                $file->write("// general info\n");
                $file->write("if (!defined('RELATIVE_WCF_DIR')) define('RELATIVE_WCF_DIR', RELATIVE_".$prefix."_DIR.'".FileUtil::getRelativePath($packageDir, WCF_DIR)."');\n");
-               $file->write("if (!defined('PACKAGE_ID')) define('PACKAGE_ID', ".$row['packageID'].");\n");
+               $file->write("if (!defined('PACKAGE_ID')) define('PACKAGE_ID', ".($row === false ? $packageID : $row['packageID']).");\n");
                $file->write("if (!defined('PACKAGE_NAME')) define('PACKAGE_NAME', '".str_replace("'", "\'", $package->getName())."');\n");
                $file->write("if (!defined('PACKAGE_VERSION')) define('PACKAGE_VERSION', '".$package->packageVersion."');\n");
                
index 0f1b9c004b8087cac30c4139813d1e7623bebeb2..389f8e6064f4c366d889dc5e86a5a366381291c2 100644 (file)
@@ -5,6 +5,9 @@ use wcf\data\package\PackageCache;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\cache\CacheHandler;
 use wcf\system\cronjob\CronjobScheduler;
+use wcf\system\exception\IPrintableException;
+use wcf\system\exception\PermissionDeniedException;
+use wcf\system\exception\SystemException;
 use wcf\system\language\LanguageFactory;
 use wcf\system\package\PackageInstallationDispatcher;
 use wcf\system\session\SessionFactory;
@@ -12,7 +15,6 @@ use wcf\system\session\SessionHandler;
 use wcf\system\style\StyleHandler;
 use wcf\system\template\TemplateEngine;
 use wcf\system\user\storage\UserStorageHandler;
-use wcf\system\exception;
 use wcf\util;
 
 // try to disable execution time limit
@@ -237,13 +239,13 @@ class WCF {
         */
        public static final function handleException(\Exception $e) {
                try {
-                       if ($e instanceof exception\IPrintableException) {
+                       if ($e instanceof IPrintableException) {
                                $e->show();
                                exit;
                        }
                        
                        // repack Exception
-                       self::handleException(new exception\SystemException($e->getMessage(), $e->getCode(), '', $e));
+                       self::handleException(new SystemException($e->getMessage(), $e->getCode(), '', $e));
                }
                catch (\Exception $exception) {
                        die("<pre>WCF::handleException() Unhandled exception: ".$exception->getMessage()."\n\n".$exception->getTraceAsString());
@@ -268,7 +270,7 @@ class WCF {
                                        break;
                        }
                        
-                       throw new exception\SystemException('PHP '.$type.' in file '.$filename.' ('.$lineNo.'): '.$message, 0);
+                       throw new SystemException('PHP '.$type.' in file '.$filename.' ('.$lineNo.'): '.$message, 0);
                }
        }
        
@@ -389,17 +391,17 @@ class WCF {
        protected function initBlacklist() {
                if (defined('BLACKLIST_IP_ADDRESSES') && BLACKLIST_IP_ADDRESSES != '') {
                        if (!util\StringUtil::executeWordFilter(WCF::getSession()->ipAddress, BLACKLIST_IP_ADDRESSES)) {
-                               throw new exception\PermissionDeniedException();
+                               throw new PermissionDeniedException();
                        }
                }
                if (defined('BLACKLIST_USER_AGENTS') && BLACKLIST_USER_AGENTS != '') {
                        if (!util\StringUtil::executeWordFilter(WCF::getSession()->userAgent, BLACKLIST_USER_AGENTS)) {
-                               throw new exception\PermissionDeniedException();
+                               throw new PermissionDeniedException();
                        }
                }
                if (defined('BLACKLIST_HOSTNAMES') && BLACKLIST_HOSTNAMES != '') {
                        if (!util\StringUtil::executeWordFilter(@gethostbyaddr(WCF::getSession()->ipAddress), BLACKLIST_HOSTNAMES)) {
-                               throw new exception\PermissionDeniedException();
+                               throw new PermissionDeniedException();
                        }
                }
        }
@@ -465,7 +467,7 @@ class WCF {
                                require_once($configPath);
                        }
                        else {
-                               throw new exception\SystemException('Unable to load configuration for '.$package->package);
+                               throw new SystemException('Unable to load configuration for '.$package->package);
                        }
                        
                        // load options
@@ -483,7 +485,7 @@ class WCF {
                }
                else {
                        unset(self::$autoloadDirectories[$abbreviation]);
-                       throw new exception\SystemException("Unable to run '".$package->package."', '".$className."' is missing or does not implement 'wcf\system\application\IApplication'.");
+                       throw new SystemException("Unable to run '".$package->package."', '".$className."' is missing or does not implement 'wcf\system\application\IApplication'.");
                }
                
                // register template path in ACP
@@ -533,7 +535,7 @@ class WCF {
                        return $this->$method();
                }
                
-               throw new exception\SystemException("method '".$method."' does not exist in class WCF");
+               throw new SystemException("method '".$method."' does not exist in class WCF");
        }
        
        /**
@@ -592,12 +594,12 @@ class WCF {
                
                $objectName = self::getCoreObject($className);
                if ($objectName === null) {
-                       throw new exception\SystemException("Core object '".$className."' is unknown.");
+                       throw new SystemException("Core object '".$className."' is unknown.");
                }
                
                if (class_exists($objectName)) {
                        if (!(util\ClassUtil::isInstanceOf($objectName, 'wcf\system\SingletonFactory'))) {
-                               throw new exception\SystemException("class '".$objectName."' does not implement the interface 'SingletonFactory'");
+                               throw new SystemException("class '".$objectName."' does not implement the interface 'SingletonFactory'");
                        }
                        
                        self::$coreObject[$className] = call_user_func(array($objectName, 'getInstance'));
index 4ddbfb309bdabe9dd54f10461217bf937cac361d..afef04fb96ba6edd9ab6296702149c432e110875 100644 (file)
@@ -75,7 +75,6 @@ class ACPMenuCacheBuilder implements ICacheBuilder {
                        $statement->execute($conditions->getParameters());
                        while ($row = $statement->fetchArray()) {
                                $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, array(
-                                       'packageID' => $packageID,
                                        'menuItem' => 'wcf.acp.option.category.'.$row['categoryName'],
                                        'parentMenuItem' => 'wcf.acp.menu.link.option.category',
                                        'menuItemLink' => 'index.php/Option/'.$row['categoryID'].'/',
index e298511a348e116642ba92e168be10f85e586af6..1014a43084a0b4e9b1795f31e596b8379a60d9fb 100644 (file)
@@ -55,6 +55,7 @@ class ApplicationCacheBuilder implements ICacheBuilder {
                // assign wcf pseudo-application
                if (PACKAGE_ID) {
                        $data['wcf'] = $data['application'][1];
+                       unset($data['application'][1]);
                }
                
                return $data;
index 6ab710f3d00dcc6343fddbe16e3cfcded3c433c0..8485a3d84f7b1447c9f0dc32c97be110f8566201 100644 (file)
@@ -17,7 +17,7 @@ class TemplateListenerCodeCacheBuilder implements ICacheBuilder {
         * @see wcf\system\cache\ICacheBuilder::getData()
         */
        public function getData(array $cacheResource) {
-               list($packageID, $environment, $templateName) = explode('-', $cacheResource['cache']); 
+               list($environment, $templateName) = explode('-', $cacheResource['cache']); 
                
                // get template codes for specified template
                $templateListenerList = new TemplateListenerList();