* adjust the file_exists logic to improve the perfomance on SAE.
This commit is contained in:
@@ -217,7 +217,7 @@ class control
|
||||
$modelFile = helper::setModelFile($moduleName);
|
||||
|
||||
/* If no model file, try load config. */
|
||||
if(!file_exists($modelFile))
|
||||
if(!helper::import($modelFile))
|
||||
{
|
||||
$this->app->loadConfig($moduleName, false);
|
||||
$this->app->loadLang($moduleName);
|
||||
@@ -225,7 +225,6 @@ class control
|
||||
return false;
|
||||
}
|
||||
|
||||
helper::import($modelFile);
|
||||
$modelClass = class_exists('ext' . $moduleName. 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model';
|
||||
if(!class_exists($modelClass)) $this->app->error(" The model $modelClass not found", __FILE__, __LINE__, $exit = true);
|
||||
|
||||
@@ -274,7 +273,7 @@ class control
|
||||
$extHookFiles = helper::ls($viewExtPath, '.hook.php');
|
||||
|
||||
$viewFile = file_exists($extViewFile) ? $extViewFile : $mainViewFile;
|
||||
if(!file_exists($viewFile)) $this->app->error("the view file $viewFile not found", __FILE__, __LINE__, $exit = true);
|
||||
if(!is_file($viewFile)) $this->app->error("the view file $viewFile not found", __FILE__, __LINE__, $exit = true);
|
||||
if(!empty($extHookFiles)) return array('viewFile' => $viewFile, 'hookFiles' => $extHookFiles);
|
||||
return $viewFile;
|
||||
}
|
||||
@@ -316,7 +315,7 @@ class control
|
||||
$mainCssFile = $modulePath . 'css' . $this->pathFix . 'common.css';
|
||||
$methodCssFile = $modulePath . 'css' . $this->pathFix . $methodName . '.css';
|
||||
if(file_exists($mainCssFile)) $css .= file_get_contents($mainCssFile);
|
||||
if(file_exists($methodCssFile)) $css .= file_get_contents($methodCssFile);
|
||||
if(is_file($methodCssFile)) $css .= file_get_contents($methodCssFile);
|
||||
return $css;
|
||||
}
|
||||
|
||||
@@ -338,7 +337,7 @@ class control
|
||||
$mainJsFile = $modulePath . 'js' . $this->pathFix . 'common.js';
|
||||
$methodJsFile = $modulePath . 'js' . $this->pathFix . $methodName . '.js';
|
||||
if(file_exists($mainJsFile)) $js .= file_get_contents($mainJsFile);
|
||||
if(file_exists($methodJsFile)) $js .= file_get_contents($methodJsFile);
|
||||
if(is_file($methodJsFile)) $js .= file_get_contents($methodJsFile);
|
||||
return $js;
|
||||
}
|
||||
|
||||
@@ -477,7 +476,7 @@ class control
|
||||
$file2Included = file_exists($actionExtFile) ? $actionExtFile : $moduleControlFile;
|
||||
|
||||
/* Load the control file. */
|
||||
if(!file_exists($file2Included)) $this->app->error("The control file $file2Included not found", __FILE__, __LINE__, $exit = true);
|
||||
if(!is_file($file2Included)) $this->app->error("The control file $file2Included not found", __FILE__, __LINE__, $exit = true);
|
||||
$currentPWD = getcwd();
|
||||
chdir(dirname($file2Included));
|
||||
if($moduleName != $this->moduleName) helper::import($file2Included);
|
||||
|
||||
@@ -118,7 +118,7 @@ class helper
|
||||
*/
|
||||
static public function import($file)
|
||||
{
|
||||
if(!file_exists($file)) return false;
|
||||
if(!is_file($file)) return false;
|
||||
static $includedFiles = array();
|
||||
if(!isset($includedFiles[$file]))
|
||||
{
|
||||
@@ -126,7 +126,7 @@ class helper
|
||||
$includedFiles[$file] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +337,6 @@ class helper
|
||||
if(!file_exists($issueFile) or !is_readable($issueFile)) return false;
|
||||
return stripos(file_get_contents($issueFile), 'centos') !== false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,9 +175,8 @@ class model
|
||||
{
|
||||
if(empty($moduleName)) return false;
|
||||
$modelFile = helper::setModelFile($moduleName);
|
||||
if(!file_exists($modelFile)) return false;
|
||||
|
||||
helper::import($modelFile);
|
||||
if(!helper::import($modelFile)) return false;
|
||||
$modelClass = class_exists('ext' . $moduleName. 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model';
|
||||
if(!class_exists($modelClass)) $this->app->error(" The model $modelClass not found", __FILE__, __LINE__, $exit = true);
|
||||
|
||||
|
||||
@@ -960,7 +960,7 @@ class router
|
||||
public function setControlFile($exitIfNone = true)
|
||||
{
|
||||
$this->controlFile = $this->moduleRoot . $this->moduleName . $this->pathFix . 'control.php';
|
||||
if(!file_exists($this->controlFile))
|
||||
if(!is_file($this->controlFile))
|
||||
{
|
||||
$this->error("the control file $this->controlFile not found.", __FILE__, __LINE__, $exitIfNone);
|
||||
return false;
|
||||
@@ -1324,13 +1324,13 @@ class router
|
||||
if(is_dir($classFile)) $classFile .= $this->pathFix . $className;
|
||||
$classFile .= '.class.php';
|
||||
|
||||
if(!file_exists($classFile))
|
||||
if(!is_file($classFile))
|
||||
{
|
||||
/* Search in $coreLibRoot. */
|
||||
$classFile = $this->coreLibRoot . $className;
|
||||
if(is_dir($classFile)) $classFile .= $this->pathFix . $className;
|
||||
$classFile .= '.class.php';
|
||||
if(!file_exists($classFile)) $this->error("class file $classFile not found", __FILE__, __LINE__, $exit = true);
|
||||
if(!is_file($classFile)) $this->error("class file $classFile not found", __FILE__, __LINE__, $exit = true);
|
||||
}
|
||||
|
||||
helper::import($classFile);
|
||||
@@ -1364,7 +1364,7 @@ class router
|
||||
{
|
||||
$mainConfigFile = $this->configRoot . 'config.php';
|
||||
$myConfig = $this->configRoot . 'my.php';
|
||||
if(file_exists($myConfig)) $extConfigFiles[] = $myConfig;
|
||||
if(is_file($myConfig)) $extConfigFiles[] = $myConfig;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1374,7 +1374,7 @@ class router
|
||||
}
|
||||
|
||||
/* Set the files to include. */
|
||||
if(!file_exists($mainConfigFile))
|
||||
if(!is_file($mainConfigFile))
|
||||
{
|
||||
if($exitIfNone) self::error("config file $mainConfigFile not found", __FILE__, __LINE__, true);
|
||||
if(empty($extConfigFiles)) return false; // and no extension file, exit.
|
||||
@@ -1434,7 +1434,7 @@ class router
|
||||
$extLangFiles = helper::ls($extLangPath . $this->clientLang, '.php');
|
||||
|
||||
/* Set the files to includ. */
|
||||
if(!file_exists($mainLangFile))
|
||||
if(!is_file($mainLangFile))
|
||||
{
|
||||
if(empty($extLangFiles)) return false; // also no extension file.
|
||||
$langFiles = $extLangFiles;
|
||||
|
||||
Reference in New Issue
Block a user