Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#33638 closed defect (bug) (fixed)

Comment template functions should accept full comment object

Reported by: wonderboymusic's profile wonderboymusic Owned by:
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Comments Keywords:
Focuses: Cc:

Description

get_comment() will accept object or ID. The comment template functions don't follow suit, so they always return the global $comment - or check the cache, then the db.

In contrast, get_post() returns the global only if nothing is passed.

Change History (17)

#1 @DrewAPicture
9 years ago

Seems like maybe we should wait for WP_Comment to add object support to the template function.

#2 @wonderboymusic
9 years ago

In 33961:

After [33891], a lot of comment functions can take WP_Comment instead of only accepting comment_ID. Update the @param docs to reflect this.

See #33638.

#3 @wonderboymusic
9 years ago

In 33963:

After [33891], get_comment() returns global $comment if no args are passed and the global is set (after setting the default to null here). This allows us to ditch global comment imports.

See #33638.

#4 @wonderboymusic
9 years ago

In 33964:

In WP_Comments_List_Table, favor passing WP_Comment instances instead of $comment_ID to template functions. This allows us to bypass unnecessary cache lookups and simply pass the object through when it is set.

See #33638.

#5 @wonderboymusic
9 years ago

In 33965:

Use get_comment() instead of a global in touch_time().

See #33638.

#6 @wonderboymusic
9 years ago

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

#7 @DrewAPicture
9 years ago

In 33979:

Docs: Add a changelog entry to the DocBlock for touch_time() to mention the shift from accessing the global $comment to using get_comment().

See #33638.

#8 @wonderboymusic
9 years ago

In 33986:

After the global churn in [33964], also set $post to null at the end of WP_Comments_List_Table::single_row() to ensure that an orphaned comment doesn't inherit the previous row's $post context.

See #33638.

#9 @wonderboymusic
9 years ago

In 34039:

After [33961], pass $comment to get_comment_author_link() where possible to avoid extra cache/db lookups.

See #33638.

#10 @wonderboymusic
9 years ago

In 34040:

After [33961], pass $comment to comment_class() where possible to avoid extra cache/db lookups.

See #33638.

#11 @wonderboymusic
9 years ago

In 34041:

After [33961], pass $comment to get_comment_date() where possible to avoid extra cache/db lookups.

See #33638.

#12 @wonderboymusic
9 years ago

In 34042:

After [33961], pass $comment to get_comment_link() where possible to avoid extra cache/db lookups.

See #33638.

#13 @wonderboymusic
9 years ago

In 34071:

Comments: comment_link() currently takes no arguments, yet get_comment_link() does. Allow comment_link() to optionally take the same arguments.

See #33638.

#14 @wonderboymusic
9 years ago

In 34129:

More comment functions can accept a full object instead of comment_ID to reduce cache/db lookups.

See ##33638.

#15 @wonderboymusic
9 years ago

In 34130:

wp_unspam_comment() can accept a full object instead of comment_ID to reduce cache/db lookups..

See #33638.

#16 @DrewAPicture
9 years ago

In 34230:

Docs: Make a minor adjustment to the description syntax for the optional $comment argument in the DocBlock for comment_link(), introduced in [34071].

See #33638. See #32246.

#17 @DrewAPicture
9 years ago

In 34237:

Docs: Add changelog entries for parameters where WP_Comment object support was added in [33961].

See #33638. See #32246.

Note: See TracTickets for help on using tickets.