Page MenuHomePhabricator

$IP wrongly calculated when includes dir is a symlink
Closed, DuplicatePublic

Description

In order to experiment with new versions (I have many custom extensions), I have mediawiki installed in /var/www/html/my-mediawiki. Inside it, include /var/www/html/my-mediawiki/includes is a symlink that points to /var/www/html/mediawiki-x.yy.z/includes.

In this scenario the $IP variable is wrongly calculated, because in line 54 of includes/WebStart.php:

$IP = dirname( __DIR__ );

$IP becomes /var/www/html/mediawiki-x.yy.z/, while it should be /var/www/html/my-mediawiki. This happes because dirname doesn't care about symlinks.

A workaround is to change that line to

$IP = dirname( $_SERVER["SCRIPT_FILENAME"] );

and $IP gets the correct value in every situation

Event Timeline

Change 466865 had a related patch set uploaded (by D3r1ck01; owner: Alangi Derick):
[mediawiki/core@master] Fix $IP value when directory is a symlink

https://gerrit.wikimedia.org/r/466865

the patch doesn't work, $_SERVER['SCRIPT_FILENAME'] must be used, not $_SERVER['SCRIPT_NAME'].