[wp-trac] [WordPress Trac] #18117: get_blog_details is sensitive to path's trailing slash

WordPress Trac noreply at wordpress.org
Wed Nov 19 03:15:04 UTC 2014


#18117: get_blog_details is sensitive to path's trailing slash
----------------------------------------+------------------------
 Reporter:  mitchoyoshitaka             |       Owner:
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  4.1
Component:  Networks and Sites          |     Version:  3.0
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  multisite
----------------------------------------+------------------------

Comment (by earnjam):

 I tried [diff:18117.3.diff] but it failed a couple of tests and kicked a
 ton of errors. Upon further investigation, I realized it was setting the
 path to `//` for the main site and causing lots of problems. This was due
 to it forcing two slashes to be added here:
 `$details[ $field ] = '/' . implode( '/', $details[ $field ] ) . '/'; `

 In [diff:18117.4.diff] I changed that line to:
 `$details[ $field ] = trailingslashit( implode( '/', $details[ $field ] )
 . '/' ); `
 That fixed the problem and now it's passing all the tests.

 I also added the tests @simonwheatley included in [diff:18117.2.diff] and
 added a few more to cover the multiple subdirectories use case that
 @jeremyfelt mentioned.

 I also had to fix some tests in `test_update_blog_details()`. They were
 attempting to update the path without a leading slash (`my-path/`) and
 asserting against that. Since we'd now be sanitizing the slashes properly
 in `update_blog_details()` that test would no longer pass because it
 checks for the wrong thing.

 So that last portion actually points out another issue. When a super admin
 updates the path of a site from `site-info.php`, it updates the `siteurl`
 and `home` url prior to running through `update_blog_details()` where we
 would now be checking the slashes. If they leave off the leading slash,
 then you end up with `http://domain.compath`. This needs to be fixed too,
 but it should probably be its own ticket.

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


More information about the wp-trac mailing list