[wp-trac] [WordPress Trac] #5305: permalinks broken when article name is numeric

WordPress Trac noreply at wordpress.org
Tue Jul 14 02:14:40 UTC 2015


#5305: permalinks broken when article name is numeric
--------------------------+---------------------------
 Reporter:  thomask       |       Owner:  valendesigns
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  4.3
Component:  Permalinks    |     Version:  2.3.1
 Severity:  major         |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+---------------------------

Comment (by boonebgorges):

 Replying to [comment:97 valendesigns]:
 > I kind of wish we had gone with an earlier more backwards compatible
 patch that allowed the URL to be whatever we want them to be and not
 append junk to the end of the slug.

 Oh pshaw. If it were easy, it would've been done years ago :)

 I did manage to reproduce the issue. Two things in
 [attachment:5305.18.diff]:

 * When no post_name is provided to `wp_insert_post()`, it falls back on
 `sanitize_title( $post_title, $post_ID )`. The `$post_ID` fallback hasn't
 needed a unique check in the past, since post IDs are unique. But now that
 `wp_unique_post_slug()` is doing a bit more work, we need to run the
 fallback title through it. (I didn't test, but it's likely that there is
 an existing bug here that's unrelated to numeric slugs: if you have a
 existing post with slug 'foo', and then try to create a post like this
 `wp_insert_post( array( 'post_name' => '', 'post_title' => 'Foo' ) )`,
 you'd probably get some weirdness. The unique check proposed here will fix
 that bonus bug.)
 * As valendesigns notes, `wp_unique_post_slug()` has no business
 suggesting a new unique slug for an existing post under normal
 circumstances. I've added a check to `wp_unique_post_slug()` that ensures
 that the numeric-slug check is only performed when the slug being checked
 is different from the one that the post already has.

 It looks like this fixes the workflows that we've discussed in the last
 couple comments. valendesigns and hkucukali, could you put
 [attachment:5305.18.diff] through its paces?

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


More information about the wp-trac mailing list