WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#30472 closed defect (bug) (fixed)

get_terms_to_edit() can return a WP_Error, but used as a string

Reported by: dd32 Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: administration Cc:

Description

As noted in #28319 get_terms_to_edit() can return string|bool|WP_Error, but in a number of places we simply treat it as a string, causing a PHP Fatal.

Attachments (1)

30472.diff (2.2 KB) - added by valendesigns 7 years ago.

Download all attachments as: .zip

Change History (5)

#1 @SergeyBiryukov
7 years ago

  • Component changed from Administration to Taxonomy
  • Focuses administration added; template removed

@valendesigns
7 years ago

#2 @valendesigns
7 years ago

  • Keywords has-patch reporter-feedback added; needs-patch removed

This patch should stop fatal PHP errors from being thrown when the value of get_terms_to_edit() is a WP_Error or boolean.

@dd32 could you please provide some information on how you caused the error in the first place so I can properly test the patch and also write unit tests if needed.

Cheers,
Derek

#3 @wonderboymusic
6 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Future Release to 4.4

#4 @wonderboymusic
6 years ago

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

In 35139:

Taxonomy: get_terms_to_edit() can also return false or WP_Error. Vars using it should be set to empty string when errors are returned to avoid producing fatal errors when used in string operations.

Props valendesigns.
Fixes #30472.

Note: See TracTickets for help on using tickets.