Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#57323 closed defect (bug) (fixed)

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

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

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 4 years ago.

Download all attachments as: .zip

Change History (5)

@mcaskill
4 years ago

#1 @costdev
4 years ago

  • Keywords commit added
  • Milestone Awaiting Review → 6.2
  • Version 6.1.1 → 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
4 years ago

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

#3 @johnbillion
4 years ago

  • Owner set to johnbillion
  • Resolution → fixed
  • Status new → 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
4 years ago

Thanks @johnbillion 🙏

Note: See TracTickets for help on using tickets.