12

I use MediaWiki but there is an error. I found it in the files. There is line with this code:

$IP = realpath( '.' );

But $IP returns an empty string, so the path to the files in the system is not working. (for example if $IP would be . or E:/path_to_wwwroot it works). How can I solve the problem. Is it possible that my provider blocked access to realpath?

Thanks!

Jordy
  • 4,719
  • 11
  • 47
  • 81

3 Answers3

18

Source: http://php.net/manual/en/function.realpath.php

Note: The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.

So your web server should have access also to pre-webroot directories.

DaveRandom
  • 87,921
  • 11
  • 154
  • 174
Alexey Morozov
  • 1,259
  • 10
  • 12
  • 2
    Ah thanks, It needs read permissions on all directory in the wwwroot? Or also the files outside the wwwroot? – Jordy Oct 26 '11 at 17:39
  • Wow, it solved the problem! Many thanks. I needed to change the read permission from my subdomain map. Thanks!!! – Jordy Oct 26 '11 at 17:40
  • I ran into this when I was running the "portable" PHP+NGINX app WT-NMP and my sandboxed PHP app was referencing libraries outside the path I specified for open_basedir in php.ini. I solved it by also adding my library path to open_basedir (using the ";" delimiter on Windows). – ftexperts Mar 25 '14 at 04:28
  • realpath on a file that does not exist also returns a blank – Graham Feb 08 '17 at 11:47
1

I am currently experiencing this result when running PHP from command line, but not within an HTTP request. Got to be config or $_SERVER settings somewhere, will update if I find the fix.

siliconrockstar
  • 3,554
  • 36
  • 33
0

The path I was creating didn't exist, make always sure that it's well formed.

This is the path I was using:

realpath(MY_PATH . '../other_path');

Where MY_PATH didn't have a trailing /.

Alberto M
  • 1,608
  • 1
  • 18
  • 42