hightman / xunsearch

免费开源的中文搜索引擎,采用 C/C++ 编写 (基于 xapian 和 scws),提供 PHP 的开发接口和丰富文档
http://www.xunsearch.com
Other
1.64k stars 391 forks source link

vendor\hightman\xunsearch\lib\XS.class.php 构造函数缺少异常处理 #21

Closed ouewqa closed 8 years ago

ouewqa commented 8 years ago
public function __construct($file)
    {
        if (strlen($file) < 255 && !is_file($file)) {
            $appRoot = getenv('XS_APP_ROOT');
            if ($appRoot === false) {
                $appRoot = defined('XS_APP_ROOT') ? XS_APP_ROOT : XS_LIB_ROOT . '/../app';
            }
            $file2 = $appRoot . '/' . $file . '.ini';
            if (is_file($file2)) {
                $file = $file2;
            } else {
                throw new \Exception(sprintf('File [%s] is not exist!', $file)); 
            }
        }
        $this->loadIniFile($file);
        self::$_lastXS = $this;
    }

我修改了类名,忘了修改配置名,结果查了好久才找到原因。这里判断配置不存在的情况,抛出异常。