From: Daniel Friesen Date: Wed, 30 Nov 2011 15:12:19 +0000 (+0000) Subject: Followup r104688, reintroduce the full PathRouter code now that the bug with url... X-Git-Tag: 1.31.0-rc.0~26212 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=fba28f5233e6a2c1c2457ef68b9609dd4db86106;p=lhc%2Fweb%2Fwiklou.git Followup r104688, reintroduce the full PathRouter code now that the bug with url encoded paths is fixed. --- diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 8eeac0c89a..d1d8391332 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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 diff --git a/docs/hooks.txt b/docs/hooks.txt index 718a0cd08f..8223ef17c7 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 9f6d277f8d..7b43c8d1b4 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -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