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

DonPaolo created this task.Oct 9 2018, 9:11 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 9 2018, 9:11 PM
Aklapper updated the task description. (Show Details)
D3r1ck01 updated the task description. (Show Details)Oct 12 2018, 11:13 AM

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'].