Fixed broken application installation
authorAlexander Ebert <ebert@woltlab.com>
Mon, 28 Jan 2013 15:34:10 +0000 (16:34 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 28 Jan 2013 15:34:10 +0000 (16:34 +0100)
Fixes #1114

wcfsetup/install/files/lib/data/package/PackageEditor.class.php
wcfsetup/install/files/lib/system/WCF.class.php

index 78dc03e1e842efa9079469c6bb0a960b2a04bd51..b1e2f09b832676db349e11609474a50f9b5416df 100644 (file)
@@ -1,20 +1,29 @@
 <?php
 namespace wcf\data\package;
 use wcf\data\DatabaseObjectEditor;
+use wcf\data\IEditableCachedObject;
+use wcf\system\cache\CacheHandler;
 
 /**
  * Provides functions to edit packages.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.package
  * @category   Community Framework
  */
-class PackageEditor extends DatabaseObjectEditor {
+class PackageEditor extends DatabaseObjectEditor implements IEditableCachedObject {
        /**
         * @see wcf\data\DatabaseObjectDecorator::$baseClass
         */
        protected static $baseClass = 'wcf\data\package\Package';
+       
+       /**
+        * @see wcf\data\IEditableCachedObject::resetCache()
+        */
+       public static function resetCache() {
+               CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.package.php');
+       }
 }
index 03bad1d060e709ed4d7b7424374be2a5596c97e8..8b667e2eee4dac657163a20b4a2fa1f629f7df5c 100644 (file)
@@ -2,7 +2,9 @@
 namespace wcf\system;
 use wcf\data\application\Application;
 use wcf\data\option\OptionEditor;
+use wcf\data\package\Package;
 use wcf\data\package\PackageCache;
+use wcf\data\package\PackageEditor;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\cache\CacheHandler;
 use wcf\system\cronjob\CronjobScheduler;
@@ -455,7 +457,20 @@ class WCF {
        protected function loadApplication(Application $application, $isDependentApplication = false) {
                $applicationObject = null;
                $package = PackageCache::getInstance()->getPackage($application->packageID);
-               
+               // package cache might be outdated
+               if ($package === null) {
+                       $package = new Package($application->packageID);
+                       
+                       // package cache is outdated, discard cache
+                       if ($package->packageID) {
+                               PackageEditor::resetCache();
+                       }
+                       else {
+                               // package id is invalid
+                               throw new SystemException("application identified by package id '".$application->packageID."' is unknown");
+                       }
+               }
+                       
                $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($application->packageID);
                $packageDir = FileUtil::getRealPath(WCF_DIR.$package->packageDir);
                self::$autoloadDirectories[$abbreviation] = $packageDir . 'lib/';