Handle FastCGI situations where PATH_INFO is not available. master
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 20 Aug 2019 04:01:43 +0000 (00:01 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 20 Aug 2019 04:01:43 +0000 (00:01 -0400)
Construct it from SCRIPT_NAME and DOCUMENT_URI.

http/front_controller.php

index d31f1ff0631ea6dce94021573d9c694964ffe34c..7e7d6099b34b97683127fd1542dbb0388debcb34 100644 (file)
@@ -94,7 +94,10 @@ class FrontController
     if (isset($data['PATH_INFO']))
       $url = $data['PATH_INFO'];
     else
-      $url = '/';
+      $url = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['DOCUMENT_URI']);
+
+    $this->request->data['HOPLITE_PATH_INFO'] = $url;
+
     if ($url[0] == '/')
       $url = substr($url, 1);
 
@@ -209,8 +212,8 @@ class FrontController
     // Detect the common paths between the REQUEST_URI and the PATH_INFO. That
     // common piece will be the path to the root controller.
     $request_uri = $this->request()->data['_SERVER']['REQUEST_URI'];
-    $path_info = $this->request()->data['_SERVER']['PATH_INFO'];
-    if ($path_info === NULL)
+    $path_info = $this->request()->data['HOPLITE_PATH_INFO'];
+    if (!$path_info)
       $common_uri = substr($request_uri, 0, -1);
     else
       $common_uri = strstr($request_uri, $path_info, TRUE);