minor typo in comment
[lhc/web/wiklou.git] / includes / WebRequest.php
index 8478e7d..c91d004 100644 (file)
@@ -55,7 +55,22 @@ class WebRequest {
                $this->data = $_POST + $_GET;
        }
 
+       /**
+        * Extract the PATH_INFO variable even when it isn't a reasonable
+        * value. On some large webhosts, PATH_INFO includes the script
+        * path as well as everything after it.
+        *
+        * @param $want string: If this is not 'all', then the function
+        * will return an empty array if it determines that the URL is
+        * inside a rewrite path.
+        *
+        * @return Array: 'title' key is the title of the article.
+        */
        static public function getPathInfo( $want = 'all' ) {
+               // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892
+               // And also by Apache 2.x, double slashes are converted to single slashes.
+               // So we will use REQUEST_URI if possible.
+               $matches = array();
                if ( !empty( $_SERVER['REQUEST_URI'] ) ) {
                        // Slurp out the path portion to examine...
                        $url = $_SERVER['REQUEST_URI'];
@@ -70,7 +85,7 @@ class WebRequest {
                                if( $path == $wgScript && $want !== 'all' ) {
                                        // Script inside a rewrite path?
                                        // Abort to keep from breaking...
-                                       return array();
+                                       return $matches;
                                }
                                // Raw PATH_INFO style
                                $matches = self::extractTitle( $path, "$wgScript/$1" );
@@ -124,9 +139,11 @@ class WebRequest {
                        return;
                }
 
-               $matches = self::getPathInfo( 'title' );
-               foreach( $matches as $key => $val) {
-                       $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
+               if ( $wgUsePathInfo ) {
+                       $matches = self::getPathInfo( 'title' );
+                       foreach( $matches as $key => $val) {
+                               $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
+                       }
                }
        }