Opened 10 years ago
Last modified 3 months ago
#37103 new defect (bug)
get_comments_number_text() should not replace '%' in post title
| Reported by: | SergeyBiryukov | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Comments | Version: | 4.2 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Background: #13651
- Create a post titled "Hello % world".
- Add a couple of comments.
comments_popup_link()will produce the following output:<a href="...">2 Comments <span class="screen-reader-text"> on Hello 2 world!</span>
Note "Hello 2 world!" instead of "Hello % world!", due to get_comments_number_text() treating % as a comments number.
Reproduced with 4.5.2 and Twenty Sixteen. Technically introduced in [31388].
Attachments (2)
Change History (12)
#3
@
10 years ago
I have a fix for this issue, but I am not sure if it's the right one. Please give me some feedback on my fix.
#6
@
10 years ago
- Keywords needs-patch needs-unit-tests added; has-patch needs-testing removed
Thanks for the patch, @andizer, but your change means that the string % Comments would be turned into 2 instead of 2 Comments.
I think the fix is to replace any % symbols in the post title with a placeholder (such as __PERCENT__), do the comment number replacement, and then swap the placeholder back out for a %.
#9
@
10 years ago
In 37103.patch the % character is replaced by __PERCENT__ in the post title for posts with more than 1 comment. After the comment number replacement is done it's replaced back to %.
I didn't remove this unit test as (I think) it's the default behavior for get_comments_number_text(). Maybe we should remove the comment though.
This ticket was mentioned in PR #13248 on WordPress/wordpress-develop by skikken.
3 months ago
#10
Trac ticket: https://core.trac.wordpress.org/ticket/37103
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Sonnet
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
https://github.com/WordPress/WordPress/blob/master/wp-includes/comment-template.php#L875