WordPress.org

Make WordPress Core

Opened 5 weeks ago

Closed 2 weeks ago

#48251 closed defect (bug) (fixed)

Remove "private" assignation from _deprecated_...() and _doing_it_wrong()

Reported by: jrf Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version: 5.3
Component: General Keywords: has-patch
Focuses: Cc:
PR Number:

Description

`_deprecated_function()` was introduced in WP 2.5.0 via [6514] in response to #4361
`_deprecated_file()` was introduced in WP 2.5.0 via [6514] in response to #4361
`_deprecated_argument()` was introduced in WP 3.0.0 via [12536] in response to #11386
`_doing_it_wrong()` was introduced in WP 3.1.0 via [16939] in response to #15824
`_deprecated_constructor()` was introduced in WP 4.3.0 via [32989] in response to #31982

All of these functions are currently marked as private.

I have not been able to discover why they were marked as private in the first place, but not withstanding that, they are widely used by plugins (13249 matches) and themes (13512 matches) anyway.

In contrast, `do_action_deprecated()` and `apply_filters_deprecated()` are not marked private.

Aside from this being inconsistent, IMO, it also doesn't make sense.

Why would plugins and themes not be allowed to use these functions to throw appropriate error notices when (add-on) plugins and (child) themes would be using functionality which the plugin/theme has deprecated ?

So, with this ticket I'd like to propose removing the private assignation from the above mentioned functions.

N.B.: I'm explicitly excluding `_deprecated_hook()` from this ticket as that function really shouldn't be called directly, but is invoked under the hood by the do_action_deprecated() and apply_filters_deprecated() functions.

Attachments (1)

48251.patch (2.6 KB) - added by jrf 5 weeks ago.
Remove private assignation from _deprecated_..() and _doing_it_wrong() functions

Download all attachments as: .zip

Change History (3)

@jrf
5 weeks ago

Remove private assignation from _deprecated_..() and _doing_it_wrong() functions

#1 @SergeyBiryukov
5 weeks ago

  • Milestone changed from Awaiting Review to 5.4

#2 @SergeyBiryukov
2 weeks ago

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

In 46602:

Docs: Remove "private" designation from _doing_it_wrong() and related functions:

  • _deprecated_function()
  • _deprecated_argument()
  • _deprecated_constructor()
  • _deprecated_file()

Plugins and themes should be allowed to use these functions to throw appropriate error notices.

This brings them in line with newer do_action_deprecated() and apply_filters_deprecated() functions, which are not marked as private.

Props jrf.
Fixes #48251.

Note: See TracTickets for help on using tickets.