Ticket #4003 (closed enhancement: fixed)

Opened 5 years ago

Last modified 5 years ago

Set 'home' and 'siteurl' options in wp-config.php

Reported by: filosofo Owned by: charleshooper
Priority: low Milestone: 2.2
Component: Administration Version:
Severity: normal Keywords: home siteurl wp-config has-patch
Cc:

Description

I can't tell you how often I end up editing the database just to change the 'siteurl' and 'home' options.

Recently on the hackers list  Matt suggested that it might have been a good thing to have put the those options in wp-config.php, and I agree.

My patch allows you to set the constants "WP_HOME" and "WP_SITEURL" in wp-config.php, in which case they will override the db settings (and gray out those fields in the admin options page).

As far as I can tell, this is something that would have to be done with a core change like this, because plugins are read too late after 'home' and 'siteurl' have already been used in wp-settings.php.

Attachments

patch.diff Download (2.6 KB) - added by filosofo 5 years ago.
trunk-4003.diff Download (4.0 KB) - added by charleshooper 5 years ago.
Updated version of patch.diff to check WP_SITEURL value during install and also change is_blog_installed to return boolean value

Change History

comment:1   ryan5 years ago

1

+100

This is the most requested feature I have seen when considering using WordPress in a staged environment.

Now we just need the facility (plugin) to fix all the absolute urls in page content that are broken when this is changed ;-)

Agreed, this would be MORE than useful, and is also the subject of at least 2 ideas in the ideas section.

 http://wordpress.org/extend/ideas/topic.php?id=70&page&replies=9  http://wordpress.org/extend/ideas/topic.php?id=142&page&replies=4

+1 googol

This will help fixing a lot of bugs.

+1, should we also update is_blog_installed() to use this new constant?

comment:7   ryan5 years ago

is_blog_installed is more of a DB check. Since we always create a siteurl option during install, I think we can leave it as is. We might want to change it to return true/false so that no one is tempted to use the return value as anything other than a bool.

+1 for the boolean return, I'll submit the patch here in a few. I did notice that in wp_install() we do a update_option('siteurl', $guessurl), I think it's a good idea to override $guessurl if WP_SITEURL is already definied

comment:9   ryan5 years ago

Checking WP_SITEURL during install sounds good.

Updated version of patch.diff to check WP_SITEURL value during install and also change is_blog_installed to return boolean value

  • Owner changed from anonymous to charleshooper
  • Status changed from new to assigned

I've added a new patch, although I'm not sure why I can't preview it :-/

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [5093]) Allow siteurl and home to be defined as constants in wp-config, bypassing the DB. Props filosofo and charleshooper. fixes #4003

  • Milestone changed from 2.3 to 2.2
Note: See TracTickets for help on using tickets.