Last modified: 2010-05-15 15:59:38 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T13428, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 11428 - $wgArticlePath = '/$1' fails if also $wgUsePathInfo set to true
$wgArticlePath = '/$1' fails if also $wgUsePathInfo set to true
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Redirects (Other open bugs)
1.11.x
All All
: High major with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-09-23 08:54 UTC by Aran
Modified: 2010-05-15 15:59 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to correct the error (932 bytes, patch)
2007-09-25 23:08 UTC, Zach Dennison
Details

Description Aran 2007-09-23 08:54:06 UTC
When $wgArticlePath is set to '/$1' for friendly URL's, $wgUsePathInfo cannot also be used. Many installs use both of these in together so that the friendly-rewrite rules map to a PathInfo based request so that un-encoded ampersands and question marks can be used in article titles which aren't allowed if using query-string.

What's happening is that the new extractTitle method in the WebRequest class is returning a title value like "Wiki/index.php" when the request's title is in the query-string. I suspect that it should not be returning anything in when the title is in the query-string and should only be returning a title key when the request is PathInfo-based.

To fix it temporarily on a number of 1.11's that it's happened to I've replaced the WebRequest constructor with the 1.10 version, and made the interpolateTitle method return before doing anything. I've put more detail at http://www.organicdesign.co.nz/MediaWiki_1.11_title_extraction_bug.
Comment 1 Brion Vibber 2007-09-24 21:24:34 UTC
What's your rewrite config?

cf also http://lists.wikimedia.org/pipermail/mediawiki-l/2007-September/023602.html
Comment 2 Aran 2007-09-25 01:18:22 UTC
Our rule for handling the friendly-url rewriting maps the host name (excluding www part) into the file path,
 RewriteCond %{REQUEST_URI} ^/(wiki/|files/|[fF]avicon.ico|[rR]obots.txt)
 RewriteCond %{HTTP_HOST} ^(www\.)?(.+)$
 RewriteRule (.*) /%2$1 [L]

 RewriteCond %{HTTP_HOST} ^(www\.)?(.+)$
 RewriteRule (.*) /%2/wiki/index.php$1 [L]
When I put ''phpinfo();die;'' into the start of ''index.php'' all the values for PATH_INFO, REQUEST_URI etc appear to be currect for for all forms of URL request eg. /foo, /wiki/index.php?title=foo, /wiki/index.php/foo. But the ''extractTitle'' function is treating the script path and name as the title even if the title is present in query-string or PATH_INFO.
Comment 3 Trevor Wennblom 2007-09-25 20:07:52 UTC
Simplest example I have -

.htaccess:

Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?title=$1 [L,QSA]


LocalSettings.php:

$wgArticlePath = "$wgScriptPath/$1";


The articles will show, but links containing index.php (such as edit) will attempt to edit an article called Index.php. This appears to be due to changes in WebRequest.php.

 diff -uN mediawiki-1.10.2/includes/WebRequest.php mediawiki-1.11.0/includes/WebRequest.php
Comment 4 Zach Dennison 2007-09-25 23:08:17 UTC
Created attachment 4158 [details]
Patch to correct the error

This patch detects if the beginning of $path is "$wgScriptPath/index$wgScriptExtension". If it is, it simply strips that from the beginning of $path, giving the results desired. The only time this should be a problem is if someone who isn't using rewrite rules wanted a URL of, say http://example.com/wiki/index.php/wiki/index.php, to make the page "Wiki/index.php", which includes the script path and script file in the page name. If desired, I could also make this only work if a variable, something like $wgEnableRewriting is set to true. (In that case, since I think this would help more people than it would hurt, if it hurts any, that the variable should be enabled by default in DefaultSettings.php.)
Comment 5 Brion Vibber 2008-01-02 20:26:57 UTC
r29191 should do it. I've used $wgScript specifically and moved it out to the interpolateTitle() loop as an intitial step.
Comment 6 Brion Vibber 2008-01-02 20:48:36 UTC
r29192 fixes a stupid cut-n-paste error I made.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links