#20494 closed enhancement (fixed)
comment_exists function return improper value
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.6 |
| Component: | Comments | Version: | 2.0 |
| Severity: | minor | Keywords: | has-patch dev-feedback |
| Cc: |
Description
Hey,
The function comment_exists() return comment_post_ID instead comment_ID
PHPdoc say:
@return mixed Comment ID on success.
I submit 2 patches, one which only corrects the bug
And an another one with an additionnal parameter for this function, post id.
Attachments (3)
Change History (14)
momo360modena — 13 months ago
comment:1
momo360modena — 13 months ago
- Summary changed from comment_exists function return inconsitly values to comment_exists function return improper value
- Version changed from 3.4 to 2.0
I imagine this has been around since 2.0.
comment:3
MikeHansenMe — 9 months ago
- Keywords dev-feedback added
- Type changed from defect (bug) to enhancement
Tested both patches and they seem to be working correctly for me.
Also updated type from bug to enhancement since it does function currently just a bit to strictly.
comment:4
SergeyBiryukov — 4 months ago
- Milestone changed from Awaiting Review to 3.6
Related: #23304
comment:5
SergeyBiryukov — 4 months ago
In 23350:
comment:6
SergeyBiryukov — 4 months ago
comment_exists() is not used in core. Since it doesn't work as intended, we should probably deprecate it.
comment_exists() and post_exists() both get used by importers, if I recall correctly.
SergeyBiryukov — 4 months ago
comment:8
in reply to:
↑ 7
;
follow-up:
↓ 10
SergeyBiryukov — 4 months ago
Replying to nacin:
comment_exists() and post_exists() both get used by importers, if I recall correctly.
Indeed.
- Blogger Importer maintains its own copy of the function:
http://plugins.trac.wordpress.org/browser/blogger-importer/trunk/blogger-importer.php#L998 - Blogware Importer, GreyMatter Importer, Movable Type Importer, and WordPress Importer don't do anything with the returned value, other than checking if it's true:
http://plugins.trac.wordpress.org/browser/blogware-importer/trunk/blogware-importer.php#L159
http://plugins.trac.wordpress.org/browser/greymatter-importer/trunk/greymatter-importer.php#L291
http://plugins.trac.wordpress.org/browser/movabletype-importer/trunk/movabletype-importer.php#L291
http://plugins.trac.wordpress.org/browser/wordpress-importer/trunk/wordpress-importer.php#L671 - DotClear Importer and TextPattern Importer treat the returned comment post ID as comment ID, which is wrong:
http://plugins.trac.wordpress.org/browser/dotclear-importer/trunk/dotclear-importer.php#L416
http://plugins.trac.wordpress.org/browser/textpattern-importer/trunk/textpattern-importer.php#L429
Seems like we have two options:
- Correct the actual return value (comment_exists_light.patch).
- Only correct the docs (20494.docs.patch).
Given the usage in DotClear Importer and TextPattern Importer, I guess the first option makes the most sense.
comment:9
SergeyBiryukov — 3 months ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 23433:
comment:10
in reply to:
↑ 8
SergeyBiryukov — 3 months ago
Replying to SergeyBiryukov:
DotClear Importer and TextPattern Importer treat the returned comment post ID as comment ID
Created #23482 for that.

Bugfix