Skip to content

Check if ABSPATH constant is defined before defining ABSPATH#4537

Closed
janw-me wants to merge 1 commit intowp-cli:masterfrom
janw-me:abspath-defined
Closed

Check if ABSPATH constant is defined before defining ABSPATH#4537
janw-me wants to merge 1 commit intowp-cli:masterfrom
janw-me:abspath-defined

Conversation

@janw-me
Copy link
Copy Markdown
Member

@janw-me janw-me commented Nov 28, 2017

If a wp-cli.yml has a require in which the ABSPATH is defined wp-cli command will throw a notice.
Example:

wp-cli.yaml

require:
     - abspath.php

abspath.php

<?php
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', dirname( __FILE__ ) . '/custom_path/wp/' );
}

When would you want this? In short symlinks, if you include WordPress in a symlink.

WordPress tries to define the ABSPATH it uses wp-load.php and if it's in a symlink it will define the path baed on the actual location. Not the symlink path.
That will give a problem if the wp-config.php is one directory above wp-load.php.

If a `wp-cli.yml` has a _require_ in which the ABSPATH is defined wp-cli command will throw a notice.
Example:

`wp-cli.yaml`

    require:
         - abspath.php

`abspath.php`

    <?php
    if ( ! defined( 'ABSPATH' ) ) {
	    define( 'ABSPATH', dirname( __FILE__ ) . '/custom_path/wp/' );
    }

When would you want this? In short symlinks, if you include WordPress in a symlink.

WordPress tries to define the ABSPATH it uses wp-load.php and if it's in a symlink it will define the path baed on the actual location. Not the symlink path.
That will give a problem if the wp-config.php is one directory above wp-load.php.
@janw-me janw-me closed this Nov 28, 2017
@danielbachhuber
Copy link
Copy Markdown
Member

@janw-oostendorp Please open an issue for discussion on substantial changes like this, thanks.

@janw-me
Copy link
Copy Markdown
Member Author

janw-me commented Nov 28, 2017

Check;
wp-cli/ideas#69

PS It might be a bit hard to explain. But the fix is a simple check which I highly doubt would give problems.

@janw-me janw-me mentioned this pull request Mar 23, 2018
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.

2 participants