Skip to content

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