[wp-trac] [WordPress Trac] #53308: The WP_CONTENT_URL constant contains an incorrect URL

WordPress Trac noreply at wordpress.org
Mon May 31 23:20:35 UTC 2021


#53308: The WP_CONTENT_URL constant contains an incorrect URL
-------------------------------+------------------------------
 Reporter:  webtemyk           |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Bootstrap/Load     |     Version:  5.7.2
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by peterwilsoncc):

 * keywords:   => reporter-feedback
 * component:  General => Bootstrap/Load


Old description:

> In one of the latest versions of WordPress, we added this code to the
> file wp-config.php:
> {{{#!php
> <?php
> if ( ! defined( 'WP_CLI' ) ) {
>         define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' .
> $_SERVER['HTTP_HOST'] );
>         define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' .
> $_SERVER['HTTP_HOST'] );
> }
> }}}
>
> However, when declaring some constants, the site URL continues to be
> taken from the option in the database:
> {{{#!php
> <?php
> define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
> }}}
>
> The problem occurs when the site administrator moves the site to another
> domain or switches to HTTPS, but does not change the URL in the database.
> At the same time, Wordpress continues to work, even with the wrong
> address in the option in the database, but the old site address turns out
> to be in the constant

New description:

 In one of the latest versions of WordPress, we added this code to the file
 wp-config.php:
 {{{#!php
 <?php
 if ( ! defined( 'WP_CLI' ) ) {
         define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' .
 $_SERVER['HTTP_HOST'] );
         define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' .
 $_SERVER['HTTP_HOST'] );
 }
 }}}

 However, when declaring some constants, the site URL continues to be taken
 from the option in the database:
 {{{#!php
 <?php
 define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
 }}}

 The problem occurs when the site administrator moves the site to another
 domain or switches to HTTPS, but does not change the URL in the database.
 At the same time, WordPress continues to work, even with the wrong address
 in the option in the database, but the old site address turns out to be in
 the constant

--

Comment:

 Hi @webtemyk and welcome to trac!

 Prior to running the code to define `WP_CONTENT_URL` WordPress adds a
 filter to override the `siteurl` and `homeurl` option if the constants are
 set, [https://github.com/WordPress/wordpress-
 develop/blob/8edfb80800be7651172099373fa1827204e04ea8/src/wp-includes
 /default-filters.php#L254-L255 the filters are added in the wp-includes
 /default-filters.php file], and the for the filters
 [https://github.com/WordPress/wordpress-
 develop/blob/8edfb80800be7651172099373fa1827204e04ea8/src/wp-
 includes/functions.php#L4267-L4309 check if the constants are defined].

 However, if you have set your site up in multisite mode these filters do
 not run. Is your site running as a multisite install?

 Thanks,
 Peter

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


More information about the wp-trac mailing list