[wp-trac] [WordPress Trac] #36174: Child posts of drafts get an extraneous slash in the permalink

WordPress Trac noreply at wordpress.org
Tue Mar 8 22:52:41 UTC 2016


#36174: Child posts of drafts get an extraneous slash in the permalink
--------------------------+-----------------------------
 Reporter:  inderpreet99  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 '''Problem'''
 Calling `get_post_permalink()` on a published child post with draft parent
 (for a hierarchical post type) comes up as `http://example.org/test//post-
 title-1/` rather than `http://example.org/test/post-title-1/`.

 '''Reproduction'''
 Reproduce bug by running the attached unit test
 `test_draft_child_post_link.php` within wp-unit-tests.

 1. Setup WP Unit Tests: https://make.wordpress.org/core/handbook/testing
 /automated-testing/phpunit/
 2. Run `phpunit test_draft_child_post_link.php`

 '''Log'''

 {{{
 wordpress-develop isingh$ phpunit test_draft_child_post_link.php
 Installing...
 Running as single site... To run multisite, use -c
 tests/phpunit/multisite.xml
 Not running ajax tests. To execute these, use --group ajax.
 Not running ms-files tests. To execute these, use --group ms-files.
 Not running external-http tests. To execute these, use --group external-
 http.
 PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

 F                                                                   1 / 1
 (100%)

 Time: 714 ms, Memory: 33.50Mb

 There was 1 failure:

 1) Test_Draft_Child_URL::test_draft_child_post_link
 Failed asserting that two strings are equal.
 --- Expected
 +++ Actual
 @@ @@
 -'http://example.org/test/post-title-1/'
 +'http://example.org/test//post-title-1/'

 /Users/isingh/Dropbox/work/wordpress-
 develop/test_draft_child_post_link.php:27

 FAILURES!
 Tests: 1, Assertions: 1, Failures: 1.
 }}}


 '''Patch'''
 * Attached as `patch_draft_child_post_link.diff`.
 * Fix the `get_page_uri()` function with an extra conditional to skip
 `post_name` when empty.

 '''Background'''

 * In the BU Navigation plugin unit tests, we have a test to generate a
 draft page and then a published child post. In the test, bu-navigation
 ends up generating a URL more correct (without the double slash), mostly
 due to the above patched check we have in a custom function.

 * This behavior was previously reported in #7915 when it was marked
 worksforme.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36174>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list