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

WordPress Trac noreply at wordpress.org
Thu May 14 19:43:28 UTC 2015


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

Comment (by boonebgorges):

 valendesigns - I'm glad we let this percolate for 4.3, because in
 revisiting it, I found some problems :) I've run out of time to work on
 the patch today, so I wanted to throw it up here for you to chew on.

 [attachment:5305.15.diff] proposes a couple of changes:

 1. Force 'wp_unique_post_slug_is_bad_[hierarchical|flat]_slug' in
 `get_sample_permalink()`. This is necessary, because when the existing
 `$post` is an auto-draft, the `post_name` in the database will be empty,
 which means that the slug won't be suffixed. I'm not a huge fan of the
 add/remove filter trick, but it's done elsewhere in core, and it's far
 simpler than any other solution I could come up with.

 2. I changed the "resolve" function name to avoid the underscore prefix.

 Unfortunately, I still don't think we're ready to move on this. A couple
 outstanding issues that I want to throw out for consideration:

 a. The `get_sample_permalink()` suffixing is too aggressive. On a typical
 WP installation, it's only 'post' objects that will have URLs that clash
 with date archives. (Objects from hierarchical post types are prevented
 from having numeric slugs; see #11917 [13424].) So perhaps we should only
 be massaging the suggested permalink if the post_type is 'post'. But are
 there cases where a CPT might have a conflicting slug? I don't think so,
 but it needs some thought.

 b. I'm having second thoughts about the `get_sample_permalink()` strategy.
 Hierarchical post type objects are prevented from having numeric slugs at
 all; see #11917 [13424]. I don't think we have to go that far, but perhaps
 we should put our date-clash enforcement at the level of
 `wp_unique_post_slug()`, if only for consistency. This will mean rewriting
 a number of our tests, since it'll no longer be possible to create
 fixtures with date-clash slugs through the unit test factory.

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


More information about the wp-trac mailing list