]> git.andy128k.dev Git - ipf.git/commitdiff
make test server faster
authorAndrey Kutejko <andy128k@gmail.com>
Tue, 11 Jun 2013 21:11:44 +0000 (00:11 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Tue, 11 Jun 2013 21:11:44 +0000 (00:11 +0300)
ipf/project.php

index f9d0e94b1cbc78fec51c1399f7a7d7f127697547..342e731967f429c920726b437d706f641163664b 100644 (file)
@@ -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;
     }
 }