Make WordPress Core

Opened 11 months ago

Last modified 10 months ago

#60328 reviewing defect (bug)

Deprecated parameter default value of unregister_setting() is not correct type

Reported by: crstauf's profile crstauf Owned by: audrasjb's profile audrasjb
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch changes-requested
Focuses: docs Cc:

Description

The parameter callable $deprecated cannot default to an empty string. It must either default to null or the type has to be changed to callable|string.

-- Reported by gerardreches via User Contributed Notes.

Change History (8)

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


11 months ago
#1

  • Keywords has-patch added

The parameter callable $deprecated cannot default to an empty string. It must either default to null or the type has to be changed to callable|string.

-- Reported by gerardreches via User Contributed Notes.

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

#2 @audrasjb
11 months ago

  • Owner set to audrasjb
  • Status changed from new to reviewing

#3 follow-up: @audrasjb
11 months ago

  • Keywords changes-requested needs-unit-tests added

Hi there, thanks for the patch.
@crstauf @gerardreches the pull request triggers some PHPUnit issues.
I think the condition if ( '' !== $deprecated ) needs to be updated to check for null. The related PHPUnit tests should probably be updated, too.

#4 in reply to: ↑ 3 @gerardreches
11 months ago

Replying to audrasjb:

Hi there, thanks for the patch.
@crstauf @gerardreches the pull request triggers some PHPUnit issues.
I think the condition if ( '' !== $deprecated ) needs to be updated to check for null. The related PHPUnit tests should probably be updated, too.

I think that for backward compatibility we should keep that condition, and then add an additional one for null:

if ( !== $deprecated && null !== $deprecated ) {

on line 2836 in option.php

#5 follow-up: @audrasjb
11 months ago

  • Keywords needs-unit-tests removed

Makes sense to me, just maybe replace && with || ;)

Removing needs-unit-tests since it wouldn't need any unit test update in that case.

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


11 months ago
#6

…not correct type

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

#7 in reply to: ↑ 5 @gerardreches
11 months ago

Replying to audrasjb:

Makes sense to me, just maybe replace && with || ;)

Removing needs-unit-tests since it wouldn't need any unit test update in that case.

Maybe I'm a bit confused, but why || instead of &&? Aren't we trying to run what's inside the conditional if $deprecated has been set to something that is not the default value?

@crstauf commented on PR #5936:


10 months ago
#8

Closing in favor of #5959.

Note: See TracTickets for help on using tickets.