From e443de20488d58764aa552389bdd4eefa2e8aff2 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Wed, 12 Jun 2013 00:11:44 +0300 Subject: [PATCH] make test server faster --- ipf/project.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) 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; } } -- 2.49.0