WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 14 months ago

Last modified 14 months ago

#20494 closed enhancement (fixed)

comment_exists function return improper value

Reported by: momo360modena Owned by: SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: minor Version: 2.0
Component: Comments Keywords: has-patch dev-feedback
Focuses: 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)

comment_exists_light.patch (815 bytes) - added by momo360modena 2 years ago.
Bugfix
comment_exists.patch (1.5 KB) - added by momo360modena 2 years ago.
bugfix + parameter post id
20494.docs.patch (507 bytes) - added by SergeyBiryukov 15 months ago.

Download all attachments as: .zip

Change History (14)

momo360modena2 years ago

Bugfix

momo360modena2 years ago

bugfix + parameter post id

comment:1 momo360modena2 years ago

  • Summary changed from comment_exists function return inconsitly values to comment_exists function return improper value

comment:2 nacin23 months ago

  • Version changed from 3.4 to 2.0

I imagine this has been around since 2.0.

comment:3 MikeHansenMe20 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 too strictly.

Last edited 20 months ago by MikeHansenMe (previous) (diff)

comment:4 SergeyBiryukov15 months ago

  • Milestone changed from Awaiting Review to 3.6

Related: #23304

comment:5 SergeyBiryukov15 months ago

In 23350:

Add missing inline descriptions.

props momo360modena, aaronholbrook.
see #20494, fixes #23304.

comment:6 SergeyBiryukov15 months ago

comment_exists() is not used in core. Since it doesn't work as intended, we should probably deprecate it.

comment:7 follow-up: nacin15 months ago

comment_exists() and post_exists() both get used by importers, if I recall correctly.

comment:8 in reply to: ↑ 7 ; follow-up: SergeyBiryukov15 months ago

Replying to nacin:

comment_exists() and post_exists() both get used by importers, if I recall correctly.

Indeed.

Seems like we have two options:

  1. Correct the actual return value (comment_exists_light.patch).
  2. 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 SergeyBiryukov14 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 23433:

Correct return value for comment_exists(). fixes #20494.

comment:10 in reply to: ↑ 8 SergeyBiryukov14 months ago

Replying to SergeyBiryukov:

DotClear Importer and TextPattern Importer treat the returned comment post ID as comment ID

Created #23482 for that.

Note: See TracTickets for help on using tickets.