Fix regression where $wgActionPaths were not respected when parsing info out of REQUE...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 14 May 2007 13:56:26 +0000 (13:56 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 14 May 2007 13:56:26 +0000 (13:56 +0000)
There may still be bugs with alternate/compatibility URLs, investigate further...

includes/WebRequest.php

index 6e9836e..1a59766 100644 (file)
@@ -51,17 +51,10 @@ class WebRequest {
                        // So we will use REQUEST_URI if possible.
                        $title = '';
                        if ( !empty( $_SERVER['REQUEST_URI'] ) ) {
-                               global $wgArticlePath;
-                               $url = $_SERVER['REQUEST_URI'];
-                               if ( !preg_match( '!^https?://!', $url ) ) {
-                                       $url = 'http://unused' . $url;
-                               }
-                               $a = parse_url( $url );
-                               // Find the part after $wgArticlePath
-                               $base = str_replace( '$1', '', $wgArticlePath );
-                               if ( $a && substr( $a['path'], 0, strlen( $base ) ) == $base ) {
-                                       $title = urldecode( substr( $a['path'], strlen( $base ) ) );
-                               }
+                               global $wgArticlePath, $wgActionPaths;
+                               $paths["view"] = $wgArticlePath;
+                               $paths = array_merge( $paths, $wgActionPaths );
+                               $title = $this->extractActionPaths( $paths );
                        } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) {
                                # Mangled PATH_INFO
                                # http://bugs.php.net/bug.php?id=31892
@@ -76,6 +69,21 @@ class WebRequest {
                }
        }
        
+       private function extractActionPaths( $paths ) {
+               $url = $_SERVER['REQUEST_URI'];
+               if ( !preg_match( '!^https?://!', $url ) ) {
+                       $url = 'http://unused' . $url;
+               }
+               $a = parse_url( $url );
+               foreach( $paths as $action => $path ) {
+                       // Find the part after $wgArticlePath
+                       $base = str_replace( '$1', '', $path );
+                       if ( $a && substr( $a['path'], 0, strlen( $base ) ) == $base ) {
+                               return urldecode( substr( $a['path'], strlen( $base ) ) );
+                       }
+               }
+       }
+       
        private $_response;
 
        /**