From: Andrey Kutejko Date: Tue, 11 Jun 2013 21:11:44 +0000 (+0300) Subject: make test server faster X-Git-Tag: 0.5~249 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=e443de20488d58764aa552389bdd4eefa2e8aff2;p=ipf.git make test server faster --- diff --git a/ipf/project.php b/ipf/project.php index f9d0e94..342e731 100644 --- a/ipf/project.php +++ b/ipf/project.php @@ -114,7 +114,19 @@ final class IPF_Project{ $cli->run(); } + private function requestedFileExists() + { + $parts = explode('?', $_SERVER['REQUEST_URI'], 2); + $path = $_SERVER['DOCUMENT_ROOT'] . urldecode($parts[0]); + return is_file($path); + } + public function run() { + $sapiName = php_sapi_name(); + + if ($sapiName === 'cli-server' && $this->requestedFileExists()) + return false; + if (IPF::get('debug')) { $this->sqlProfiler = new IPF_ORM_Connection_Profiler(); IPF_ORM_Manager::getInstance()->dbListeners[] = $this->sqlProfiler; @@ -122,19 +134,14 @@ final class IPF_Project{ IPF_ORM_Manager::getInstance()->openConnection(IPF::get('database', IPF::get('dsn'))); - if (php_sapi_name() == 'cli'){ + if ($sapiName === 'cli') { $this->cli(); - return true; - } - if (php_sapi_name() == 'cli-server') { - $parts = explode('?', $_SERVER['REQUEST_URI'], 2); - $path = $_SERVER['DOCUMENT_ROOT'] . $parts[0]; - if (is_file($path)) - return false; + } else { + $this->loadModels(); + $this->router = new IPF_Router(); + $this->router->dispatch(IPF_HTTP_URL::getAction()); } - $this->loadModels(); - $this->router = new IPF_Router(); - $this->router->dispatch(IPF_HTTP_URL::getAction()); + return true; } }