Opened 8 years ago
Last modified 6 days ago
#41180 new defect (bug)
ABSPATH definition - incorrect on chrooted vhost
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.8 |
Component: | Bootstrap/Load | Keywords: | has-patch needs-testing |
Focuses: | performance | Cc: |
Description
ABSPATH defined in wp-load.php (and in other files) returns incorrect string on chrooted vhosts (double slash '/' instead of a single):
<?php if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', dirname( __FILE__ ) . '/' ); }
On chrooted vhost - output of dirname( FILE ) is '/' and no need to add additional '/' at the end of string.
It would be nice if the ABSPATH definition looked like the following:
<?php if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', ('/' === dirname( __FILE__ )) ? dirname( __FILE__ ) : dirname( __FILE__ ) . '/' ); }
Attachments (1)
Change History (8)
#5
@
7 months ago
- Keywords needs-refresh added
The underlying code has changed a bit so this will need to be refreshed. The ternary in the define is a bit hard to read, I think something a bit more explicit like
// Ensure ABSPATH isn't set as double slash if ( __DIR__ === '/' ) { define( 'ABSPATH', __DIR__ ); } else { define( 'ABSPATH', __DIR__ . '/' ); }
I also don't have a chrooted vhosts env setup to test this. I would love if a shared host that has one would reach out so I could test this before committing it.
#6
@
5 months ago
It can be simplified to this:
<?php define( 'ABSPATH', rtrim( __DIR__, '/' ) . '/' );
This ticket was mentioned in PR #8496 on WordPress/wordpress-develop by @sukhendu2002.
6 days ago
#7
- Keywords needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/41180
Hi @dacartpl, welcome to Core Trac! If you're willing, I'd encourage you to upload a patch yourself, either diffed against https://develop.svn.wordpress.org or http://develop.git.wordpress.org, your preference.
For more on contributing patches, see submitting a patch in our core handbook.