Page MenuHomePhabricator

NoLocalSettings.php doesn't tolerate rewrite rules
Closed, ResolvedPublic

Description

If you visit a not installed wiki not via script path (http://example.com/w/), but via path created by rewrite rules (http://example.com/wiki/), you will see that the usual "Please set up the wiki first" message fails to display the MediaWiki logo because its relative URL is /wiki/skins/common/images/mediawiki.png. Probably, just link to the mw.org one?


Version: 1.16.x
Severity: trivial

Details

Reference
bz21215

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:50 PM
bzimport set Reference to bz21215.
bzimport added a subscriber: Unknown Object (MLST).

karun.84 wrote:

From looking at includes/templates/NoLocalSettings, it prefixes skins/common/images/mediawiki.png with the $path variable.
As it is relative, I propose removing $path from the image source.

karun.84 wrote:

Patch for review

I have completed a patch that fixes the relative path. It needs review.

attachment 21215-v1.patch ignored as obsolete

A few comments:

  • <img src="<?php echo htmlspecialchars( $path ) ?>skins/common/images/mediawiki.png" alt='The MediaWiki logo' />

+ <img src="skins/common/images/mediawiki.png" alt='The MediaWiki logo' />

What if MediaWiki is not set up in server root? This is a pretty common situation, by the way.

  • <?php

+ <?phpr

Please try to preview your patches before submitting, otherwise such mistakes will be inavoidable.

By the way, same applies to the "set up the wiki" link which leads to something like /wiki/config/index.wiki with rewrite rules.

karun.84 wrote:

(In reply to comment #3)

A few comments:

  • <img src="<?php echo htmlspecialchars( $path )

?>skins/common/images/mediawiki.png" alt='The MediaWiki logo' />
+ <img src="skins/common/images/mediawiki.png" alt='The MediaWiki
logo' />

What if MediaWiki is not set up in server root? This is a pretty common
situation, by the way.

skins/common/images/mediawiki.png is a relative path, so if they go to http://localhost/wiki or http://localhost/w
the web browser will get the image from the urls http://localhost/wiki/skins/common/images/mediawiki.png or http://localhost/w/skins/common/images/mediawiki.png

karun.84 wrote:

Patch that replaces path to image with relative path

Attached:

(In reply to comment #5)

skins/common/images/mediawiki.png is a relative path, so if they go to
http://localhost/wiki or http://localhost/w
the web browser will get the image from the urls
http://localhost/wiki/skins/common/images/mediawiki.png or
http://localhost/w/skins/common/images/mediawiki.png

And /wiki/skins/common/images/mediawiki.png is translated by rewrite rules to something like

/w/index.php?title=skins/common/images/mediawiki.png

so your patch doesn't work.

Don't play around with this bug or close if without explanations.

Reporter, please update patch to take comment 7 into account.

(In reply to comment #0)

If you visit a not installed wiki not via script path (http://example.com/w/),
but via path created by rewrite rules (http://example.com/wiki/), you will see
that the usual "Please set up the wiki first" message fails to display the
MediaWiki logo because its relative URL is
/wiki/skins/common/images/mediawiki.png.

Ugh, that's because we don't know the real script path yet...we've gotten here via rewrite rules and $wgScriptPath is useless.

Probably, just link to the mw.org one?

That's one solution. Only other way I can think of would be getting the dirname and trying to guess. But that's very likely to fail.