Make WordPress Core

#58064 closed defect (bug) (fixed)

In the comment_time function, the call to the get_comment_time function is incorrect.

Reported by: tmatsuur's profile tmatsuur Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.2.1 Priority: normal
Severity: normal Version: 6.2
Component: Comments Keywords: has-patch has-unit-tests fixed-major
Focuses: Cc:

Description

The parameter $comment_id was added to the comment_time function in version 6.2, but it is not correctly passed on to the get_comment_time function called in it.

Current:

echo get_comment_time( $format, $comment_id );

Corrected content:

echo get_comment_time( $format, false, true, $comment_id );

Change History (9)

#1 @johnbillion
13 months ago

  • Milestone changed from Awaiting Review to 6.2.1

Introduced in [55287]

#2 @ugyensupport
13 months ago

Bug Report
Description

In the comment_time function, the call to the get_comment_time function is incorrect.

Environment

WordPress: 6.2
PHP: 8.0.0
Server: Apache/2.4.10 (Debian)
Database: mysqli (Server: 5.5.59-MariaDB-1~wheezy / Client: 5.5.62)
Browser: Chrome 111.0.0.0 (macOS)
Theme: Twenty Twenty-Three 1.1
MU-Plugins: None activated
Plugins:
Gutenberg 15.4.0
WordPress Beta Tester 3.3.7

Steps to Reproduce

The parameter $comment_id was added to the comment_time function in version 6.2, but it is not correctly passed on to the get_comment_time function called in it.
Current:

echo get_comment_time( $format, $comment_id );

Corrected content:

echo get_comment_time( $format, false, true, $comment_id );

Expected Results

✅ Looks good to me

Actual Results

❌ Looking forward to add this changes in 6.2.1

#3 @johnbillion
13 months ago

  • Keywords needs-patch needs-unit-tests added

This ticket was mentioned in PR #4305 on WordPress/wordpress-develop by @costdev.


13 months ago
#4

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

In WordPress 6.2, the $comment_id parameter was added to the get_comment_time() and comment_time() functions.

However, comment_time() made a call to get_comment_time() with missing arguments, resulting in incorrect results.

This change adds the missing arguments to this call and includes tests.

Trac ticket: https://core.trac.wordpress.org/ticket/58064

#5 @costdev
13 months ago

PR 4305 adds the missing arguments and unit tests.


Introduced in [55287], a follow-up to [55284] (both in #52322).

#6 @SergeyBiryukov
13 months ago

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

In 55632:

Comments: Add missing arguments for get_comment_time() in comment_time().

In a recent change, comment_time() was updated to accept a $comment_id parameter for consistency with comment_date(), following a similar change for get_comment_time().

However, the new parameter was not correctly passed to get_comment_time() inside the function. It should be passed as the fourth parameter after $format, $gmt and $translate, not the second.

This commit adds the missing arguments and a few unit tests to confirm the correct behavior.

Follow-up to [55284], [55287], [55308].

Props costdev, tmatsuur, ugyensupport, johnbillion.
Fixes #58064.

@SergeyBiryukov commented on PR #4305:


13 months ago
#7

Thanks for the PR! Merged in r55632.

#8 @SergeyBiryukov
13 months ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 6.2.1.

#9 @SergeyBiryukov
13 months ago

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

In 55634:

Comments: Add missing arguments for get_comment_time() in comment_time().

In a recent change, comment_time() was updated to accept a $comment_id parameter for consistency with comment_date(), following a similar change for get_comment_time().

However, the new parameter was not correctly passed to get_comment_time() inside the function. It should be passed as the fourth parameter after $format, $gmt and $translate, not the second.

This commit adds the missing arguments and a few unit tests to confirm the correct behavior.

Follow-up to [55284], [55287], [55308].

Props costdev, tmatsuur, ugyensupport, johnbillion.
Merges [55632] to the 6.2 branch.
Fixes #58064.

Note: See TracTickets for help on using tickets.