Make WordPress Core

#57690 closed defect (bug) (fixed)

The get_delete_post_link function uses the deprecated parameter

Reported by: krunal265's profile krunal265 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.2 Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords: has-patch commit php81
Focuses: coding-standards Cc:

Description

https://developer.wordpress.org/reference/functions/get_delete_post_link/
The parameter "null" at position 2 of get_delete_post_link() has been deprecated since WordPress version 3.0.0. We can use "" instead.

File path: wp-admin/includes/meta-boxes.php
Line number: 475

Attachments (1)

57690.patch (821 bytes) - added by krunal265 20 months ago.
Patch added

Download all attachments as: .zip

Change History (4)

@krunal265
20 months ago

Patch added

#1 follow-up: @jrf
20 months ago

  • Keywords commit php81 added
  • Milestone changed from Awaiting Review to 6.2

@krunal265 Thanks for this ticket and the patch. I've reviewed the issue and the patch and I concur this is the correct fix.

Two questions:

  1. Would it be possible to add a unit test for the function to safeguard the fix against regressions ?
  2. Might it be a good idea to do a code search of the whole WP Core code base for all uses of the get_delete_post_link() function to review and verify that this issue doesn't exist in more places ?

Note for committers: the patch as-is can go in. Potential results from follow-up actions resulting from my questions can be handled separately (and tests can still go in during beta).

#2 in reply to: ↑ 1 @SergeyBiryukov
20 months ago

Replying to jrf:

Would it be possible to add a unit test for the function to safeguard the fix against regressions ?

Good question:

  • The $deprecated parameter is not used in the get_delete_post_link() function itself, aside from throwing a _deprecated_argument() notice.
  • attachment_submit_meta_box() is the only function in core that passes this parameter as null instead of an empty string.
  • Passing null, while technically incorrect, still works as expected and does not trigger the deprecated argument notice, as null is considered an empty value.

So it's not immediately clear to me how to write a test case for this. We can follow up later if anyone comes up with an idea :)

Might it be a good idea to do a code search of the whole WP Core code base for all uses of the get_delete_post_link() function to review and verify that this issue doesn't exist in more places ?

There appears to be only one other instance in core where this parameter is passed to get_delete_post_link(), and it's correctly passed as an empty string there.

#3 @SergeyBiryukov
20 months ago

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

In 55306:

Coding Standards: Pass correct value to get_delete_post_link() in attachment_submit_meta_box().

The $deprecated parameter of get_delete_post_link() is documented to accept a string, not null.

Follow-up to [14099], [21948].

Props krunal265, jrf.
Fixes #57690.

Note: See TracTickets for help on using tickets.