WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years 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 3 years ago.
Bugfix
comment_exists.patch (1.5 KB) - added by momo360modena 3 years ago.
bugfix + parameter post id
20494.docs.patch (507 bytes) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (14)

@momo360modena3 years ago

Bugfix

@momo360modena3 years ago

bugfix + parameter post id

comment:1 @momo360modena3 years ago

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

comment:2 @nacin3 years ago

  • Version changed from 3.4 to 2.0

I imagine this has been around since 2.0.

comment:3 @MikeHansenMe3 years 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.

Version 0, edited 3 years ago by MikeHansenMe (next)

comment:4 @SergeyBiryukov3 years ago

  • Milestone changed from Awaiting Review to 3.6

Related: #23304

comment:5 @SergeyBiryukov3 years ago

In 23350:

Add missing inline descriptions.

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

comment:6 @SergeyBiryukov3 years ago

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

comment:7 follow-up: @nacin3 years ago

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

@SergeyBiryukov3 years ago

comment:8 in reply to: ↑ 7 ; follow-up: @SergeyBiryukov3 years 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 @SergeyBiryukov3 years 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 @SergeyBiryukov3 years 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.