Skip to content
Browse files

WebStart: Remove use of realpath() for $IP

When installing MediaWiki in a sub directory of document root,
and including it from an /index.php file in the document root,
MediaWiki succesfully includes WebStart from index.php, but
WebStart.php fails to include Setup.php.

For example, MediaWiki installation at /var/www/mediawiki with the
following file at /var/www/index.php.

require __DIR__ . '/mediawiki/index.php';


> Fatal error:
> require_once(): Failed opening required '/var/www/includes/Setup.php'
> (include_path='.:/usr/local/lib/php') in
> /var/www/mediawiki/includes/WebStart.php on line 97
> Stack trace:
>   1. {main}() /var/www/index.php:0
>   2. require() /var/www/index.php:3
>   3. require() /var/www/mediawiki/index.php:40

Bug: T153882
Change-Id: Icd8cfa580ce1c22bc3bf177570a9f4a940d2427c
  • Loading branch information...
Krinkle committed Nov 28, 2017
1 parent 8d6a9af commit 0d5f8f6bee296c4e29f03acbd5c07f34d6c8a88a
Showing with 2 additions and 5 deletions.
  1. +2 −5 includes/WebStart.php
@@ -50,13 +50,10 @@
# its purpose.
define( 'MEDIAWIKI', true );
# Full path to working directory.
# Makes it possible to for example to have effective exclude path in apc.
# __DIR__ breaks symlinked includes, but realpath() returns false
# if we don't have permissions on parent directories.
# Full path to the installation directory.
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
$IP = realpath( '.' ) ?: dirname( __DIR__ );
$IP = dirname( __DIR__ );
// If no LocalSettings file exists, try to display an error page

1 comment on commit 0d5f8f6


This comment has been minimized.

Copy link

commented on 0d5f8f6 Apr 23, 2019

In we have a wiki farm (multiple language wikis) setup in the following way:

{DocumentRoot}/wiki <- this folder contains the common mediawiki code for all the wikis

{DocumentRoot}/w-en <- this folder contains symbolic links to wiki + LocalSettings.php for english
{DocumentRoot}/w-es <- this folder contains symbolic links to wiki + LocalSettings.php for spanish
(There are 24 languages setup like this)

Every folder contains a different wiki, and apache manages the multiple languages using Alias directive, like:
Alias /en {DocumentRoot}/w-en/index.php
Alias /es {DocumentRoot}/w-es/index.php

The setup worked perfect on version 1.27 - when we migrated to version 1.32 it stopped working - it was showing the message that the wiki was not installed.
Finally I traced the problem to this change, the LocalSettings.php cannot be found because the IP was pointing to the folder {DocumentRoot}/wiki which doesn't have LocalSettings.php - every language wiki has one different.

I edited the WebStart.php reverting this change and now the wiki is working fine.


Carlos Ruiz

reported here:

Please sign in to comment.
You can’t perform that action at this time.