<?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');
+ }
}
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;
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/';