Make WordPress Core

Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#57323 closed defect (bug) (fixed)

get_settings_errors() inline docs return should reflect the array of arrays

Reported by: mcaskill's profile mcaskill Owned by: johnbillion's profile johnbillion
Milestone: 6.2 Priority: normal
Severity: normal Version: 5.6
Component: Options, Meta APIs Keywords: has-patch commit
Focuses: docs Cc:

Description

The function returns an array of setting error arrays but the inline doc suggests it returns only a single setting error array. This causes problems with static analysis tools and can be misinterpreted by developers.

This issue is present since 5.6: https://core.trac.wordpress.org/changeset/48760

Attachments (1)

57323.diff (1.9 KB) - added by mcaskill 18 months ago.

Download all attachments as: .zip

Change History (5)

@mcaskill
18 months ago

#1 @costdev
18 months ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 6.2
  • Version changed from 6.1.1 to 5.6

Hi @mcaskill, thanks for opening this ticket and well spotted!

Just a quick note that the Version property of tickets refers to the version that introduced the issue, which as you noted in the ticket description, was 5.6.

While [48760] changed @return array to add more detail, I agree that this could be clearer to avoid confusion.

For others' reference, here's a sample return value of get_settings_errors():

array (
  0 => 
  array (
    'setting' => 'new_admin_email',
    'code' => 'invalid_new_admin_email',
    'message' => 'The email address entered did not appear to be a valid email address. Please enter a valid email address.',
    'type' => 'error',
  ),
);

The patch looks good to me. Adding for commit consideration.

#2 @mcaskill
18 months ago

Thanks @costdev for the correction to the ticket and the added details.

#3 @johnbillion
18 months ago

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

In 54963:

Options, Meta APIs: Correct the documented return type for get_settings_errors().

This function returns an array of settings errors arrays.

Props mcaskill, costdev

Fixes #57323

#4 @mcaskill
18 months ago

Thanks @johnbillion 🙏

Note: See TracTickets for help on using tickets.