Make WordPress Core

Opened 11 years ago

Closed 8 years ago

Last modified 8 years ago

#26592 closed feature request (fixed)

Allow ABSPATH to be set outside of wp-load.php

Reported by: jeichorn's profile jeichorn Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.6 Priority: normal
Severity: normal Version: 3.8
Component: Bootstrap/Load Keywords: 4.6-early has-patch
Focuses: Cc:


When wp-load.php is a symlink ABSPATH gets set to a value that works for most things but is incorrect. The most obvious problem is paths to plugin assets will 404. Rather than solve this immediate problem it seems easier to allow for ABSPATH to be set outside of wp-load. That way it covers any other use cases and doesn't add a performance hit.

Adding an "if (!defined('ABSPATH'))" before defining the value would cover things.

It might be nice to also change wp-cron.php to check for a different constant, maybe even something like WP_LOADED, but its less important since its a special case that is easy to work around.

Attachments (1)

26592.diff (1.9 KB) - added by barry 8 years ago.

Download all attachments as: .zip

Change History (15)

#1 @joshua.strebel
11 years ago

ABSPATH at top of wp-admin/admin.php as well

#2 @dd32
11 years ago

Can you explain a situation such as this with a bit more detail, preferably with an example?

ABSPATH is set to the canonical location of the files, and shouldn't be used to determine the location of plugin files or URL's.

It somewhat sounds like you need to define WP_CONTENT_DIR + WP_CONTENT_URL in your environment, but I'm not sure.

#4 @jeichorn
11 years ago

There are a couple of things going on.

The first is that every config constant is user definable except for ABSPATH

The second was, the plugin dir was just an example of the problems (and you are correct that setting WP_CONTENT_DIR should fix that).

Looking at my notes more, the unsolvable problem is loading wp-config.php

In our case wp-load.php lives in /wordpress/wp-load.php
The wp-config.php lives in /username/current/wp-config.php
wp-load.php tries to load wp-config using ABSPATH and fails.

It might be slightly better (some symlinks aren't required) to make the location of wp-config.php an overridable constant rather then making ABSPATH, but thats a more complicated solution

#5 @nacin
11 years ago

  • Component changed from General to Bootstrap/Load

#6 @SergeyBiryukov
10 years ago

  • Version changed from trunk to 3.8

#7 @SergeyBiryukov
10 years ago

#29626 was marked as a duplicate.

#8 @nacin
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

I don't see a pressing need to support this. If you wanted, you could put a wp-config.php file in /wordpress/ or at / that simply includes the wp-config.php file from /username/current/. (You'd probably want a shared configuration anyway if you're already sharing all of the WordPress files.)

I also don't see where you would define ABSPATH to be outside of wp-load.php. In wp-config.php? You're trying to find wp-config.php, that's why we need ABSPATH to begin with. wp-load.php is one of the first files included; there's no place for such a define to go.

ABSPATH cannot be modified directly, and I'd like to keep it that way. It means less mistakes, less weirdness, less unsupported setups.

#9 @barry
8 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Going to reopen this one. I would like to define ABSPATH outside of WordPress as well - in my case I would like to define it in something loaded via auto_prepend_file. It's possible today, but because of the lack of a defined() check in wp-load.php we generate PHP Notices. I don't really see any harm in wrapping the ABSPATH define in wp-load.php in a if ( !defined('ABSPATH') ) check like it is in wp-config-sample.php Defining ABSPATH outside of WordPress in my use case actually leads to less complexity, not more.

Last edited 8 years ago by barry (previous) (diff)

#10 @SergeyBiryukov
8 years ago

  • Keywords needs-patch added
  • Milestone set to Awaiting Review

8 years ago

#11 @barry
8 years ago

  • Keywords has-patch added; needs-patch removed

Patch attached.

#12 @rmccue
8 years ago

  • Keywords 4.6-early added
  • Milestone changed from Awaiting Review to Future Release

I see no problems with this, so long as we do it early to catch any breakage nice and early in the cycle.

#13 @SergeyBiryukov
8 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from reopened to closed

In 37207:

Bootstrap/Load: Allow for ABSPATH to be defined outside of wp-load.php, e.g. in a script loaded via auto_prepend_file.

Props barry.
Fixes #26592.

#14 @SergeyBiryukov
8 years ago

  • Milestone changed from Future Release to 4.6
Note: See TracTickets for help on using tickets.