Followup r104688, reintroduce the full PathRouter code now that the bug with url...
authorDaniel Friesen <dantman@users.mediawiki.org>
Wed, 30 Nov 2011 15:12:19 +0000 (15:12 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Wed, 30 Nov 2011 15:12:19 +0000 (15:12 +0000)
RELEASE-NOTES-1.19
docs/hooks.txt
includes/WebRequest.php

index 8eeac0c..d1d8391 100644 (file)
@@ -40,7 +40,6 @@ production.
 * Installer now issues a warning if mod_security is present.
 * (bug 29455) Add support for a filter callback function in jQuery byteLimit
   plugin.
-* Extensions can now participate in the extraction of titles from url paths.
 * Added two new GetLocalURL hooks to better serve extensions working on a
   limited type of titles.
 * Added a --no-updates flag to importDump.php that skips updating the links
index 718a0cd..8223ef1 100644 (file)
@@ -2191,14 +2191,8 @@ $title: Title object
 $redirect: whether the page is a redirect
 $skin: Skin object
 
-'WebRequestGetPathInfoRequestURI': while extracting path info from REQUEST_URI.
-       Allows an extension to extend the extraction of titles from paths.
-       Implementing hooks should follow the pattern used in core:
-       * Use the `$matches = WebRequest::extractTitle` pattern
-       * Ensure that you test `if ( !$matches ) {` before you try extracting a title
-         from the path so that you don't override an already found match.
-$path: The request path to extract a title from.
-&$matches: The array to apply matches to.
+'WebRequestPathInfoRouter': While building the PathRouter to parse the REQUEST_URI.
+$router: The PathRouter instance
 
 'WikiExporter::dumpStableQuery': Get the SELECT query for "stable" revisions
 dumps
index 9f6d277..7b43c8d 100644 (file)
@@ -93,40 +93,49 @@ class WebRequest {
                                        // Abort to keep from breaking...
                                        return $matches;
                                }
+                               
+                               $router = new PathRouter;
+
                                // Raw PATH_INFO style
-                               $matches = self::extractTitle( $path, "$wgScript/$1" );
+                               $router->add( "$wgScript/$1" );
 
-                               if( !$matches
-                                       && isset( $_SERVER['SCRIPT_NAME'] )
+                               if( isset( $_SERVER['SCRIPT_NAME'] )
                                        && preg_match( '/\.php5?/', $_SERVER['SCRIPT_NAME'] ) )
                                {
                                        # Check for SCRIPT_NAME, we handle index.php explicitly
                                        # But we do have some other .php files such as img_auth.php
                                        # Don't let root article paths clober the parsing for them
-                                       $matches = self::extractTitle( $path, $_SERVER['SCRIPT_NAME'] . "/$1" );
+                                       $router->add( $_SERVER['SCRIPT_NAME'] . "/$1" );
                                }
 
                                global $wgArticlePath;
-                               if( !$matches && $wgArticlePath ) {
-                                       $matches = self::extractTitle( $path, $wgArticlePath );
+                               if( $wgArticlePath ) {
+                                       $router->add( $wgArticlePath );
                                }
 
                                global $wgActionPaths;
-                               if( !$matches && $wgActionPaths ) {
-                                       $matches = self::extractTitle( $path, $wgActionPaths, 'action' );
+                               if( $wgActionPaths ) {
+                                       $router->add( $wgActionPaths, array( 'action' => '$key' ) );
                                }
 
                                global $wgVariantArticlePath, $wgContLang;
-                               if( !$matches && $wgVariantArticlePath ) {
-                                       $variantPaths = array();
+                               if( $wgVariantArticlePath ) {
+                                       /*$variantPaths = array();
                                        foreach( $wgContLang->getVariants() as $variant ) {
                                                $variantPaths[$variant] =
                                                        str_replace( '$2', $variant, $wgVariantArticlePath );
                                        }
-                                       $matches = self::extractTitle( $path, $variantPaths, 'variant' );
+                                       $router->add( $variantPaths, array( 'parameter' => 'variant' ) );*/
+                                       // Maybe actually this?
+                                       $router->add( $wgVariantArticlePath,
+                                               array( 'variant' => '$2'),
+                                               array( '$2' => $wgContLang->getVariants() )
+                                       );
                                }
 
-                               wfRunHooks( 'WebRequestGetPathInfoRequestURI', array( $path, &$matches ) );
+                               wfRunHooks( 'WebRequestPathInfoRouter', array( $router ) );
+
+                               $matches = $router->parse( $path );
                        }
                } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) {
                        // Mangled PATH_INFO