[wp-trac] [WordPress Trac] #39311: New user activation welcome page links to the wrong site

WordPress Trac noreply at wordpress.org
Tue Jun 25 21:32:05 UTC 2019


#39311: New user activation welcome page links to the wrong site
-------------------------------------+------------------------------
 Reporter:  tmoore41                 |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Login and Registration   |     Version:  4.7
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  multisite
-------------------------------------+------------------------------

Comment (by pkarjala):

 Because of the change from using `network_site_url()` to using
 `wp_lostpassword_url()` for generating the reset your password text on the
 `wp-activate.php` page, I am working on a new solution.  However,
 `wp_lostpassword_url()` makes a call to `network_site_url()` to generate
 the link, so I will be focusing on `network_site_url()`.  This is in
 WordPress 5.3-alpha-45565.

 The fix, instead, may be to correct or amend the functionality of
 `network_site_url()` to properly return the current path if the user is on
 a `subdomain` or on a `subfolder` network site.  Currently,
 `network_site_url()` will properly parse and handle `subdomain` networks.
 But it fails to properly process and present `subfolder` network sites.

 Thus, it may be better to check for whether the network install is
 `subdomain` or `subfolder`, and then modify the path accordingly.

 One potential suggestion is to modify the `$path` variable in
 `network_site_url()` and `network_home_url()` as follows

 {{{#!php
 diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
 index 77b18c6fca..7e29cfa82d 100644
 --- a/wp-includes/link-template.php
 +++ b/wp-includes/link-template.php
 @@ -3373,6 +3373,13 @@ function network_site_url( $path = '', $scheme =
 null ) {
                 $url = set_url_scheme( 'http://' .
 $current_network->domain . $current_network->path, $scheme );
         }

 +       if ( SUBDOMAIN_INSTALL === false ) {
 +               $current_blog = get_blog_details();
 +               if ( $current_blog->path != '/' ) {
 +                       $path = $current_blog->path . $path;
 +               }
 +       }
 +
         if ( $path && is_string( $path ) ) {
                 $url .= ltrim( $path, '/' );
         }
 @@ -3423,6 +3430,13 @@ function network_home_url( $path = '', $scheme =
 null ) {
                 $url = set_url_scheme( 'http://' .
 $current_network->domain . $current_network->path, $scheme );
         }

 +       if ( SUBDOMAIN_INSTALL === false ) {
 +               $current_blog = get_blog_details();
 +               if ( $current_blog->path != '/' ) {
 +                       $path = $current_blog->path . $path;
 +               }
 +       }
 +
         if ( $path && is_string( $path ) ) {
                 $url .= ltrim( $path, '/' );
         }
 }}}

 I am still testing, but this does cover the specific use cases where the
 network setup is `subfolder` one.  Will add a .patch in a bit.  My primary
 concern is other places where `network_site_url()` and
 `network_home_url()` are in use.

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


More information about the wp-trac mailing list