Opened 15 years ago
Last modified 7 weeks ago
#16230 new defect (bug)
Category slugs not cut at 200 characters as it should under some conditions
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.1 |
| Component: | Taxonomy | Keywords: | needs-patch needs-refresh |
| Focuses: | Cc: |
Description
When a category name is longer than 200 characters, it is cut to 200 and so is the slug automatically created upon category creation.
Now, if you edit the category name or slug afterwards, again trying to set a name longer than 200 characters it is cut again.
But, if you edit the name or slug and use a very long string like this one:
%d1%85%d1%80%d0%b0%d0%bd%d0%b0/%d1%80%d0%b5%d1%86%d0%b5%d0%bf%d1%82%d0%b8/%d0%b4%d0%b5%d1%81%d0%b5%d1%80%d1%82%d0%b8-%d1%80%d0%b5%d1%86%d0%b5%d0%bf%d1%82%d0%b8-%d1%85%d1%80%d0%b0%d0%bd%d0%b0/%d1%81%d0%bb%d0%b0%d0%b4%d0%ba%d0%b8%d1%88%d0%b8-%d0%b4%d0%b5%d1%81%d0%b5%d1%80%d1%82%d0%b8-%d1%80%d0%b5%d1%86%d0%b5%d0%bf%d1%82%d0%b8-%d1%85%d1%80%d0%b0%d0%bd%d0%b0-%d1%80%d0%b5%d1%86%d0%b5%d0%bf%d1%/
Then the slug ends up being longer than the 200 chars limit.
Now if on the Categories list dashboard page you have more categories than visible on one page, and the category you edited above is not on page 1, the page it is on will appear empty (while successive pages will be all right if they contain regular categories)
This has been reproduced on 3.1-RC2-17283
Attachments (2)
Change History (9)
#1
@
15 years ago
#6
@
7 months ago
Bug fix: Ensure category slugs are truncated to 200 characters before insertion to match expected limits.
#7
@
7 weeks ago
- Keywords needs-refresh added; needs-testing removed
Patch Testing Report
Patch Tested:
https://core.trac.wordpress.org/attachment/ticket/16230/16230-Category-slug-length-fix.diff
Environment
- WordPress: 7.0-alpha-61215-src
- PHP: 8.2.29
- Server: nginx/1.29.4
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 143.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Two 2.1
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.1
Steps taken
- Created multiple categories to ensure pagination in the Categories admin screen.
- Created a new category with a normal name.
- Edited the category slug and pasted a very long non-English string.
- Repeated the test using a very long URL-encoded string containing multiple path segments.
- Observed the saved slug length in the database and in the admin UI.
- Navigated to the Categories list page and paginated to the page containing the edited category.
- Applied the patch and repeated all steps.
- ❌ Patch is failing
Expected result
- Category slugs should be truncated to a maximum of 200 characters regardless of input type.
- Long non-English and URL-encoded slug values should not bypass the length limit.
- The Categories admin list should not render empty pages when paginating.
A question aside: do we actually need to store slugs in urlencoded form? It only allows 66 chars for non-English slugs. It still should be enough for most cases, but is noticeably less than the original 200 characters limit.