Skip to content

Commit

Permalink
Fixed ConfigService cache bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xujiajun committed Oct 20, 2017
1 parent cabbc4c commit 1e3fa09
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Framework/Config/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function register()
$configCacheFile = self::$configCacheDir . "/config.php";

$config = $this->getConfig($configCacheFile, __BASEDIR__ . '/config/config.yml');

$this->registerAppConfig($config);
date_default_timezone_set($this->app['timezone']);
$this->registerBusinessConfig($config);
Expand All @@ -43,7 +42,7 @@ public function parseResource($resource, $isCustom)
if (true == $isCustom) {
$configResourceDir = self::$configCacheDir . "/" . substr($resource, 0, -11);
$configCacheFile = $configResourceDir . "/config.php";
$config = $this->getConfig($configCacheFile, __BASEDIR__ . "/src/{$resource}");
$config = $this->getConfig($configCacheFile, __BASEDIR__ . "/src/{$resource}", $isCustom, $configResourceDir);
}

if (false == $isCustom) {
Expand Down Expand Up @@ -181,7 +180,7 @@ private function registerBusinessConfig($configs)
}
}

private function getConfig($configCacheFile, $parseFile)
private function getConfig($configCacheFile, $parseFile, $isCustom = false, $configResourceDir = "")
{
if (file_exists($configCacheFile)) {
return require $configCacheFile;
Expand All @@ -195,8 +194,13 @@ private function getConfig($configCacheFile, $parseFile)
$configs = YamlService::parse(file_get_contents($parseFile));
}

$configCacheDir = "";
if ($isCustom) {
$configCacheDir = $configResourceDir;
}

if ($this->enabledCache) {
$this->createCache($configs, $configCacheFile);
$this->createCache($configs, $configCacheFile, $configCacheDir);
}

return $configs;
Expand Down

0 comments on commit 1e3fa09

Please sign in to comment.