Opened 10 years ago
Closed 10 years ago
#38766 closed defect (bug) (fixed)
Post type templates ignore the last post type if there is a trailing full stop.
| Reported by: | peterwilsoncc | Owned by: | peterwilsoncc |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.7 |
| Component: | Posts, Post Types | Version: | 4.7 |
| Severity: | normal | Keywords: | has-patch has-unit-tests commit |
| Cc: | Focuses: | template |
Description
Trailing full stops can cause the template post type comment to ignore the final post type.
// Works Template post type: page, post // Fails Template post type: page, post.
Incoming patch modifies the regular expression to exclude any trailing full stops and trailing whitespace.
Attachments (3)
Change History (11)
#3
@
10 years ago
- Keywords has-unit-tests 2nd-opinion added; needs-unit-tests removed
Unit tests added in 38766.2.diff.
After a second opinion, is regex's u modifier bad for performance?
#4
@
10 years ago
- Keywords needs-refresh needs-unit-tests added; has-unit-tests 2nd-opinion removed
Some things:
- If we're going to change how this works, I think the correct way would be to use
sanitize_key()on the post type, the same asregister_post_type()does. So, instead of$type = trim( $type );, have$type = sanitize_key( $type );. That removes the need for changing the regex. - The tests don't test for trailing spaces. The tests could probably be expanded to test for other invalid characters.
- The
Umodifier (invert greediness) is not the same as theumodifier (UTF-8 compatibility). The former is incorrect, and we don't need to use the latter, as only a subset of ASCII characters are allowed in post types.
#5
@
10 years ago
- Keywords has-unit-tests added; needs-refresh needs-unit-tests removed
@pento thanks for the regex explanation.
In 38766.3.diff:
- additional tests for trailing punctuation and white space.
- switch to
sanitize_key() - test to ensure invalid character ignored.
This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.
10 years ago
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Missed it by this much... :0