Support » Plugin: LocalCurrency » Different location of wp-config

  • Robbie_berns

    (@robbernsteinzgmailcom)


    Hi

    This looks like a great plugin, but I’m struggling to make it work.

    My problem is that I’m running nginx, and wp-config is 1 level above the root (ie /var/www/booqs.net/wp-config.php) however wp-settings is in the root (/var/www/booqs.net/htdocs/wp-settings.php).

    I have hacked getexchangerate.php to accommodate wp-config, but can’t seem to solve the path for wp-settings:
    PHP Fatal error: require_once(): Failed opening required '/var/www/booqs.net/wp-settings.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/booqs.net/wp-config.php on line 84

    I’m sure it’s a minor fix, but I can’t get my head around it!

    Thanks in advance
    ROB

    https://wordpress.org/plugins/localcurrency/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Stephen Cronin

    (@stephencronin)

    Hi Rob,

    How embarrassing! I need to update the plugin so that it doesn’t do Ajax calls to the server that way. There are now more robust ways to handle this, that probably wouldn’t have given you any problem, but I wrote the plugin before they existed. I have plans to do a major update to address this and other things, but probably not until the end of the year now.

    Anyway, let’s try to get you going with the current version. The wp-settings.php file is in the root folder, as you point out. Of course, getexchangerate.php has the following line:

    require_once(ABSPATH . 'wp-settings.php');

    However, this is redundant in most cases because the same line is now normally included in wp-config.php as well. The wp-config line will fire first and it is using require_once (so it will only load that file once, the first time it is called). That means the line in getexchangerate.php will not actually do anything.

    To clear up things while we are troubleshooting, please remove that line from getexchangerate.php. I expect you will get the same error message. If you do, then we know this is coming from wp-config.php. I’m pretty confident this is the case as the error message actually tells us this – it is saying the error happens “in /var/www/booqs.net/wp-config.php on line 84”.

    So please go to line 84 in wp-config and see what it says. It will probably be the same as the line I asked you to remove. It looks like it is calling wp-settings.php in the booqs.net folder (ie the level above root). So perhaps you just need to tweak the path it is using. However, it’s probably using the ABSPATH constant.

    If you look higher up in wp-config, you’ll probably see something like this:

    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');

    This is where ABSPATH is defined and it is basically saying “if it’s not already defined, then use the current directory”. The error message fits ABSPATH being set to the current directory, ie the directory that wp-config is in, which is of course wrong! So you probably need to replace

    dirname(__FILE__) . '/'

    with the actual path.

    If I’m right, that will fix the problem! All the signs point to this being the cause, except….

    If ABSPATH is set to the wrong directory, then things will be breaking all over the place, not just in LocalCurrency. This is used by many plugins and themes and most importantly, by WordPress itself.

    Anyway, please have a look at wp-config and see what’s on line 84. Thanks!

    Cheers,
    Stephen

    Robbie_berns

    (@robbernsteinzgmailcom)

    Thanks for your quick reply, Stephen.

    Yes, my wp-config is exactly as you say, but all the other plugins are working fine with that setting. Changing that causes chaos!

    Thanks
    ROB

    Plugin Author Stephen Cronin

    (@stephencronin)

    Hi Rob,

    Sorry for the delay. That’s really strange! Did you remove the following line from getexchangerate.php:

    require_once(ABSPATH . 'wp-settings.php');

    If that’s been removed then that would confirm that the error isn’t coming from there. Although the error message itself says it’s coming from wp-config’s require_once, not from LocalCurrency’s require_once, so that probably doesn’t matter.

    Where does the error message actually show up? If it’s coming from LocalCurrency, then it should only appear in getexchangerate.php (that’s the only time it requires wp-config or wp-settings). But getexchangerate.php doesn’t output anything to the page itself, it only returns some values to an Ajax call, so you wouldn’t see that error on the actual page load. You’d see it in the returned HTTP request for the Ajax call, which would only show up in something like HTTPFox or Chrome Web Developer tools (or maybe the error_log).

    Or does it appear when you load getexchangerate.php directly in the browser?

    If the error appears in once of those places, then we’ll keep digging. If it appears somewhere else, then it may not be coming from LocalCurrency at all (in which case, please deactivate LocalCurrency and see whether the problem still occurs).

    I’ll wait to hear back where it shows up! Thanks.

    Cheers,
    Stephen

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Different location of wp-config’ is closed to new replies.