Paladox has uploaded a new change for review. https://gerrit.wikimedia.org/r/309575
Change subject: Revert "MediaWiki.php: Redirect non-standard title urls to canonical" ...................................................................... Revert "MediaWiki.php: Redirect non-standard title urls to canonical" This reverts commit 155d555b83eca6403e07d2094b074a8ed2f301ae. Change-Id: I3c29131ea2041fa7429eae5fab5fae04e39f3da0 --- M includes/MediaWiki.php M tests/phpunit/includes/MediaWikiTest.php 2 files changed, 11 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/75/309575/1 diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 5510d35..932dea2 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -279,8 +279,6 @@ * - Normalise empty title: * /wiki/ -> /wiki/Main * /w/index.php?title= -> /wiki/Main - * - Normalise non-standard title urls: - * /w/index.php?title=Foo_Bar -> /wiki/Foo_Bar * - Don't redirect anything with query parameters other than 'title' or 'action=view'. * * @return bool True if a redirect was set. @@ -291,6 +289,8 @@ if ( $request->getVal( 'action', 'view' ) != 'view' || $request->wasPosted() + || ( $request->getVal( 'title' ) !== null + && $title->getPrefixedDBkey() == $request->getVal( 'title' ) ) || count( $request->getValueNames( array( 'action', 'title' ) ) ) || !Hooks::run( 'TestCanonicalRedirect', array( $request, $title, $output ) ) ) { @@ -305,19 +305,7 @@ } // Redirect to canonical url, make it a 301 to allow caching $targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); - - if ( $targetUrl != $request->getFullRequestURL() ) { - $output->setSquidMaxage( 1200 ); - $output->redirect( $targetUrl, '301' ); - return true; - } - - // If there is no title, or the title is in a non-standard encoding, we demand - // a redirect. If cgi somehow changed the 'title' query to be non-standard while - // the url is standard, the server is misconfigured. - if ( $request->getVal( 'title' ) === null - || $title->getPrefixedDBkey() != $request->getVal( 'title' ) - ) { + if ( $targetUrl == $request->getFullRequestURL() ) { $message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . @@ -339,7 +327,9 @@ } throw new HttpError( 500, $message ); } - return false; + $output->setSquidMaxage( 1200 ); + $output->redirect( $targetUrl, '301' ); + return true; } /** diff --git a/tests/phpunit/includes/MediaWikiTest.php b/tests/phpunit/includes/MediaWikiTest.php index e196243..df94d3e 100644 --- a/tests/phpunit/includes/MediaWikiTest.php +++ b/tests/phpunit/includes/MediaWikiTest.php @@ -34,7 +34,7 @@ 'url' => 'http://example.org/w/index.php?title=Foo_Bar', 'query' => array( 'title' => 'Foo_Bar' ), 'title' => 'Foo_Bar', - 'redirect' => 'http://example.org/wiki/Foo_Bar', + 'redirect' => false, ), array( // View: Script path with implicit title from page id @@ -76,21 +76,21 @@ 'url' => 'http://example.org/w/?title=Foo_Bar', 'query' => array( 'title' => 'Foo_Bar' ), 'title' => 'Foo_Bar', - 'redirect' => 'http://example.org/wiki/Foo_Bar', + 'redirect' => false, ), array( // View: Root path with escaped title 'url' => 'http://example.org/?title=Foo_Bar', 'query' => array( 'title' => 'Foo_Bar' ), 'title' => 'Foo_Bar', - 'redirect' => 'http://example.org/wiki/Foo_Bar', + 'redirect' => false, ), array( // View: Canonical with redundant query 'url' => 'http://example.org/wiki/Foo_Bar?action=view', 'query' => array( 'action' => 'view' ), 'title' => 'Foo_Bar', - 'redirect' => 'http://example.org/wiki/Foo_Bar', + 'redirect' => false, ), array( // Edit: Canonical view url with action query @@ -104,7 +104,7 @@ 'url' => 'http://example.org/w/index.php?title=Foo_Bar&action=view', 'query' => array( 'title' => 'Foo_Bar', 'action' => 'view' ), 'title' => 'Foo_Bar', - 'redirect' => 'http://example.org/wiki/Foo_Bar', + 'redirect' => false, ), array( // Edit: Index with action query -- To view, visit https://gerrit.wikimedia.org/r/309575 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3c29131ea2041fa7429eae5fab5fae04e39f3da0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Paladox <thomasmulhall...@yahoo.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits