[wp-trac] [WordPress Trac] #5276: Allow wp-config.php to be used without including wp-settings.php

WordPress Trac noreply at wordpress.org
Thu Feb 27 07:36:24 UTC 2025


#5276: Allow wp-config.php to be used without including wp-settings.php
--------------------------------------+-----------------------
 Reporter:  mastermind                |       Owner:  (none)
     Type:  enhancement               |      Status:  reopened
 Priority:  normal                    |   Milestone:
Component:  General                   |     Version:  2.5
 Severity:  normal                    |  Resolution:
 Keywords:  wp-config.php standalone  |     Focuses:
--------------------------------------+-----------------------
Changes (by lev0):

 * status:  closed => reopened
 * resolution:  wontfix =>


Comment:

 WordPress has changed considerably since this ticket was opened, but the
 problem hasn't. It is currently impossible to `include` the main config
 file from one's own or third party code.

 Replying to [comment:16 jacobsantos]:
 > No traction in 8 months
 I've always found this to be a deficiency in WP, and begrudgingly accepted
 it. At the time it seemed unfixable. I believe that's no longer the case,
 and backwards-compatible change is possible.
 > it is easy to parse the wp-config.php file to get the values of the
 defines.
 This is false. Parsing PHP is non-trivial. Not all defines are simple
 scalar values. Popular plugins I use/have used stumble over `const`-style
 declarations, or redefine constants that already exist. The only reliable
 method to determine the values is execution, so why make it difficult to
 do so? What's the benefit to the WP ecosystem in general?

 Replying to [comment:17 DD32]:
 > This was basically achieved when wp-load.php was implemented.
 Not as far I can tell. All sample and active config files I've seen,
 including the current source code, boot WP after the "stop editing!" line.
 `wp-load.php` mainly finds and loads the config file, or dies. The config
 file still plays an active role in the boot sequence

 I can't see any advantage to do it this way, nothing else in core directly
 loads the config file. The front- and back-ends both boot through `wp-
 load.php`. If one visits the config file URL, WP boots but then gives a
 WSOD, because neither `wp()` nor any other code is called after that, so
 the result is effectively the same as the config file omitting the final
 `require_once`.

 Is WP really expected to be bootable just by including the config file?
 All that would do is bypass the `error_reporting()` and cause a non-
 graceful failure in the event no config files exist. If so, is it too much
 to ask the few doing this to instead include the loader, or additionally
 include the settings file themselves, perhaps in version 7.0?

 If I move the regular inclusion of `wp-settings.php` to the `wp-load.php`,
 I find WP operates normally, and is sufficient to 'free' the config. There
 exist other inclusions of the settings code, in tests, etc., but none that
 also use the loader.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/5276#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list