Handle case where path to config.core.php includes symlinks. #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
connector.php
currently uses the PHP magic constant__FILE__
to specify the current directory and then traverses up using thedirname()
function to locateconfig.core.php
.Our installation of MODX revolution has its resources directory outside the core directory, and includes it via a symlink instead, with the installation directory being
/srv/modx/revolution/
$ ls -l /srv/modx/revolution/
includes the following lines:... lrwxrwxrwx 1 apache apache 9 Feb 16 17:00 assets -> ../assets ... -rw-r--r-- 1 apache apache 101 Mar 19 15:15 config.core.php ...
Since PHP 4.0.2,
__FILE__
always contains an absolute path with symlinks resolved.In our particular case
__FILE__
resolves to/srv/modx/assets/components/formsave
.config.core.php
is found nowhere on that path (it's in/srv/modx/revolution/
) soconnector.php
fails when trying to open the "view stored forms" component in MODX manager. The following message appears in the apache error log:[Sat Apr 12 18:48:58 2014] [error] [client <IP address removed>] PHP Fatal error: require_once(): Failed opening required '/srv/config.core.php' (include_path='.:/usr/share/pear:/usr/share/php') in /srv/modx/assets/components/formsave/connector.php.new on line 32, referer: <removed>
A possible work-around is to copy
/srv/modx/revolution/config.core.php
to/srv/config.core.php
.This patch replaces the use of
__FILE__
with$_SERVER["SCRIPT_FILENAME"]
as suggested in this StackOverflow question. I've tested this on MODX Revolution 2.2.13-pl (git) and it works without having to resort to copying config.core.php.Fixes #19