[wp-trac] [WordPress Trac] #9444: Allow to read wp-config.php without loading WP
WordPress Trac
noreply at wordpress.org
Wed Aug 19 22:36:58 UTC 2015
#9444: Allow to read wp-config.php without loading WP
--------------------------------------------------+----------------------
Reporter: hakre | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: General | Version: 2.7.1
Severity: normal | Resolution: wontfix
Keywords: has-patch tested commit dev-feedback | Focuses:
--------------------------------------------------+----------------------
Comment (by scottmas):
It's not elegant, and may potentially break in some future Wordpress
release, but it is possible to load just the configuration information
without bootstrapping all of Wordpress.
Simply read the config file as a string and get rid of the offending
require_once and then eval it.
$configString = file_get_contents('some/path/to/wp-config.php');
$configString = preg_replace('/require_once\(.*?\);/', '',
$configString);
$configString = str_replace(['<?php', '<?', '?>'], '', $configString);
eval($configString);
--
Ticket URL: <https://core.trac.wordpress.org/ticket/9444#comment:36>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list