Make WordPress Core

Opened 6 weeks ago

Last modified 6 weeks ago

#63257 accepted defect (bug)

sanitize_term_field missing default $context value

Reported by: dilipbheda's profile dilipbheda Owned by: audrasjb's profile audrasjb
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:

Description

As per the inline documentation of the sanitize_term_field() function, a default $context value should be passed in the function arguments.

Change History (5)

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


6 weeks ago
#1

#2 @audrasjb
6 weeks ago

  • Keywords 2nd-opinion added

Hello and thank you for the ticket.
I may be wrong but to be honest, given the default condition passes through a simple else statement, I cannot see much value to pass the default value. It is not used anywhere in the function.

#3 @dilipbheda
6 weeks ago

@audrasjb You're right, but I noticed that the documentation mentions a Default value, which implies that if the last parameter is not passed, it should default to the 'display' context.
Ref: https://tinyurl.com/22neh87o

Or we can remove the default value mentioned in the inline docs.

#4 @Presskopp
6 weeks ago

Defining the default $context = 'display' avoids errors if the function gets called without the $context parameter so it's making sense to me. For that reason it will be possible to also call the function with only the first 4 parameters, if needed. Also it is clearer in regards to the inline documentation.

Last edited 6 weeks ago by Presskopp (previous) (diff)

#5 @audrasjb
6 weeks ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 6.9
  • Owner set to audrasjb
  • Status changed from new to accepted

You make a point @Presskopp. Let's add the default then.

Note: See TracTickets for help on using tickets.