Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlinks issue #17

Open
jbogdani opened this issue Oct 18, 2014 · 3 comments
Open

Symlinks issue #17

jbogdani opened this issue Oct 18, 2014 · 3 comments

Comments

@jbogdani
Copy link

Hello I'm having issues using mbtiles-php inside a symlinked folder.
The main issue is related to line 607:
$here = str_replace("\\", "/", realpath(rtrim(dirname(__FILE__), '/')) . "/");

FILE resolves symlinks and so does realpath. This prevent the route to be resolved...

I actually solved changing this line to:

$here = str_replace("\\", "/", rtrim(dirname($_SERVER["SCRIPT_FILENAME"]), '/') . "/");

ie. replacing __FILE__ with $_SERVER["SCRIPT_FILENAME"] and removing any reference to realpath().

Of course this dirty workaround fixes the issue on paths containing symlink, but breaks the program on "normal" paths...

@infostreams
Copy link
Owner

Are you sure it breaks the "normal" paths? I just tried it on my Mac here and with your fix it actually handles both cases without problems (with or without symlink). Which link breaks?

Also, thanks for this :-)

@infostreams
Copy link
Owner

I replaced my code with yours. I tried to reproduced the problems you mention, but I couldn't. I tried using a symlink to 'tileserver.php' from a regular folder, and that worked, and I tried symlinking the whole folder, and that worked as well. I could even symlink a folder that contained a symlink to the tileserver.php, all without issues. What does your directory structure look like, and when/how does it break?

@jbogdani
Copy link
Author

Hello,
I think that the main error I've getting is generated in the lines where $here and $document_root are defined.
The combination:
$here = str_replace("", "/", rtrim(dirname($_SERVER["SCRIPT_FILENAME"]), '/') . "/");
and
$document_root = str_replace("", "/", realpath($_SERVER["DOCUMENT_ROOT"]) . "/");

is not working for me (I can send you a private link if needed) because $document_root symlinks are resolved by realpath function.

Actually my solution was to remove this function from here. I'm actually using (successfully) in my different locations:

$here = str_replace("\\", "/", rtrim(dirname($_SERVER["SCRIPT_FILENAME"]), '/') . "/");
$document_root = str_replace("\\", "/", $_SERVER["DOCUMENT_ROOT"] . "/");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants