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

Handle case where path to config.core.php includes symlinks. #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

graphiclunarkid
Copy link

connector.php currently uses the PHP magic constant __FILE__ to specify the current directory and then traverses up using the dirname() function to locate config.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/) so connector.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

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

Successfully merging this pull request may close these issues.

FormSave Manager Component can't find config.core.php when assets folder in non standard location
1 participant