소스 검색

Update: 不去修改配置文件的创建时间,将生成文件的时间改为配置文件的时间

朱金辉 2 년 전
부모
커밋
75c6714023
1개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 6 4
      src/Config/Register.php

+ 6 - 4
src/Config/Register.php

@@ -18,6 +18,8 @@
 namespace Qii\Config;
 
 use \Qii\Autoloader\Psr4;
+use Qii\Exceptions\InvalidFormat;
+use Qii\Exceptions\Variable;
 
 class Register
 {
@@ -83,7 +85,7 @@ class Register
 	 */
 	public static function get($key, $default = null)
 	{
-		if (!$key) throw new \Qii\Exceptions\Variable(\Qii::i(1003), __LINE__);
+		if (!$key) throw new Variable(\Qii::i(1003), __LINE__);
 		//优先调用存在的get方法
 		$method = 'get' . $key;
 		if (method_exists('\Qii\Config\Register', $method)) return Register::$method();
@@ -135,9 +137,9 @@ class Register
 	 */
 	public static function ini($fileName)
 	{
-		if (!$fileName) throw new \Qii\Exceptions\Variable(\Qii::i(1408), __LINE__);
+		if (!$fileName) throw new Variable(\Qii::i(1408), __LINE__);
 		$ini = parse_ini_file($fileName, true);
-		if (!$ini) throw new \Qii\Exceptions\InvalidFormat($fileName, __LINE__);
+		if (!$ini) throw new InvalidFormat($fileName, __LINE__);
 		$config = array();
 		foreach ($ini AS $namespace => $properties) {
 			$properties = Register::feval($properties);
@@ -268,7 +270,7 @@ class Register
 		//如果文件不可写,touch就有问题,就不写缓存文件
 		if (self::$isWrite && is_writeable($iniFile)) {
 			file_put_contents($cacheFile, "<?php \n return " . var_export($common, true) . "\n?>", LOCK_EX);
-			touch($iniFile);
+            touch($cacheFile, filemtime($iniFile));
 		}
 		Register::set($cacheName, $common);
 		return $common;