WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 7 months ago

#10970 new enhancement

Remove 'siteurl' setting from options-general.php

Reported by: scribu Owned by:
Priority: normal Milestone: Future Release
Component: Administration Version:
Severity: normal Keywords: has-patch
Cc: scribu@…, mike.schroder@…, ipstenu@…, mdhansen@…

Description

From #10957:

azaozz:

Better to fix the cause for this: "WordPress address" (siteurl) shouldn't be changeable from Settings->General at all as it cannot be set safely there. Most users would just break their blogs if they change it.

It is set at install and only needs changing when WordPress is moved to another domain or (sub)directory. This happens very rarely and there are other (better?) ways to set siteurl.

Denis-de-Bernardy:

in this case, we need to make sure the www. pref is passed on to the site_url. else we're bound to get massive bugs (e.g. #9873)

Attachments (4)

10970.diff (2.1 KB) - added by scribu 3 years ago.
Remove siteurl field from options-general.php
10970.2.diff (2.7 KB) - added by scribu 3 years ago.
Make www preference consistent
10970.3.diff (2.4 KB) - added by scribu 3 years ago.
instead of removing the siteurl field, just disable it
siteurl.php (2.2 KB) - added by nacin 3 years ago.
From dd32.

Download all attachments as: .zip

Change History (31)

comment:1 k_nitin_r4 years ago

Shouldn't we add an option to prevent redirecting from WordPress entirely? Some people have a localhost installation and would prefer to share their new development with other developers over a network. Editing the wp-config or changing the configuration setting value is an added inconvenience.

comment:2 hakre4 years ago

Related: #10957 (Use the RELOCATE constant to fix blogs.)

@k_nitin_: There will be always need for configuration. Configuration means that you actually can control the application which is a very important aspect of using it.

It looks to me that the topic is to find how to deal best with known problems.

scribu3 years ago

Remove siteurl field from options-general.php

comment:3 scribu3 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 3.0

scribu3 years ago

Make www preference consistent

comment:4 scribu3 years ago

The second patch also addresses #9873

comment:5 scribu3 years ago

  • Cc scribu@… added

comment:6 follow-up: azaozz3 years ago

The patch looks good but I'm thinking about the UI: do we show the siteurl (not changeable) and do we test for upper case characters in home? Or perhaps can test any new value for home with JS and try to match it to siteurl showing a warning if mismatched because of different case? Can possibly handle the www. matching from JS too.

comment:7 hakre3 years ago

Is there a way to setup this value in setup? Or is this done autmatically?

Related?!: #10447

If this commit comes in, supporters will be glad to have a tool at hand that changes a site's siteurl.

comment:8 in reply to: ↑ 6 scribu3 years ago

Replying to azaozz:

The patch looks good but I'm thinking about the UI: do we show the siteurl (not changeable) and do we test for upper case characters in home? Or perhaps can test any new value for home with JS and try to match it to siteurl showing a warning if mismatched because of different case? Can possibly handle the www. matching from JS too.

We could show it disabled, for reference.

I think the validation should first be done on the PHP level and then we can think about validation on the UI level.

Is there a way to setup this value in setup? Or is this done autmatically?

It's done automatically on setup.

If you really wanted to change it, I think you could do it with a custom install.php.

comment:9 scribu3 years ago

If this commit comes in, supporters will be glad to have a tool at hand that changes a site's siteurl.

You could still use options.php to change it.

comment:10 scribu3 years ago

Marked #11934 as dup of this.

scribu3 years ago

instead of removing the siteurl field, just disable it

comment:11 scribu3 years ago

  • Keywords commit added

10970.3.diff keeps the siteurl field for reference.

nacin3 years ago

From dd32.

comment:12 scribu3 years ago

Regarding siteurl.php:

That check is pretty sweet. The question is: are there any cases where you won't get an error?

If so, are they common enough to warrant the existence of the field?

comment:13 scribu3 years ago

In the IRC, wpmuguru pointed out that a user moving to a different domain could safely change the SITEURL from the admin.

That's fine, but that doesn't happen so often that it has to be part of Core. The same could be said for the 'home' option.

We could remove these two fields and write a plugin with the following options:

  • www preference
  • make homepage be different from the directory you installed WordPress

Also, as said before, advanced users can edit the options directly by going to wp-admin/options.php

comment:14 dd323 years ago

IMO, The fields need to stay as part of Core, Its a core setting which the user may need to change, Whilst it doesnt happen that often to most users, its required often enough to be included.

Theres an ancient ticket somewhere that i wrote that code for, I cant find it now however (And havnt been able to for awhile, all i remember was Matt gave it a +1 i believe)

If anything, I think the fields should be replaced with a wizard, Else, Just some checking and preventing users from setting it to something invalid would suffice.

Also, I think the www. prefix is being forced the wrong way around in that patch, SiteURL should enforce its prefix upon homeurl, not the other way around?

comment:15 scribu3 years ago

Also, I think the www. prefix is being forced the wrong way around in that patch, SiteURL should enforce its prefix upon homeurl, not the other way around?

It's the other way around because in the patch, the homeurl is the only one that can be changed.

comment:16 Denis-de-Bernardy3 years ago

I use this, myself:

	function readonly_url() {
		$home_url = get_option('home');
		$site_url = get_option('siteurl');
		
		$home_www = strpos($home_url, '://www.') !== false;
		$site_www = strpos($site_url, '://www.') !== false;
		
		if ( $home_www != $site_www ) {
			if ( $home_www )
				$site_url = str_replace('://', '://www.', $site_url);
			else
				$site_url = str_replace('://www.', '://', $site_url);
			update_option('siteurl', $site_url);
		}
		
		if ( !defined('WP_HOME') )
			define('WP_HOME', $home_url);
		if ( !defined('WP_SITEURL') )
			define('WP_SITEURL', $site_url);
	} # readonly_url()

No-one has broken a site since.

comment:17 scribu3 years ago

  • Keywords commit removed
  • Milestone changed from 3.0 to Future Release

Guess this isn't ready for 3.0.

comment:18 scribu3 years ago

Similar: #10970

comment:19 mrmist3 years ago

Related #14865, I'd like to see one or t'other, don't mind which :)

comment:20 nacin2 years ago

  • Keywords 3.2-early added

We like this for when we re-do the settings API.

This should probably be a wizard or something, and hidden where possible, and validated (see dd32's plugin) otherwise.

comment:21 DH-Shredder13 months ago

  • Cc mike.schroder@… added

comment:22 Ipstenu10 months ago

  • Cc ipstenu@… added

comment:23 nacin10 months ago

  • Keywords 3.2-early removed
  • Milestone changed from Future Release to 3.5

comment:24 MikeHansenMe7 months ago

  • Cc mdhansen@… added

comment:25 nacin7 months ago

  • Milestone changed from 3.5 to Future Release

comment:26 MikeHansenMe7 months ago

I would really like to see this in 3.6. I cannot count how many times I have had clients try to adjust this and break it.

comment:27 Ipstenu7 months ago

Is there any possibility of getting this to work for Multisite as well?

I've been seeing a rash of people changing foo.domain.com to foo.com and wondering why it broke their site.

Note: See TracTickets for help on using tickets.