WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#53913 closed defect (bug) (fixed)

Check theme API response is not an error before operating on it

Reported by: pierlo Owned by: SergeyBiryukov
Milestone: 5.9 Priority: normal
Severity: normal Version: trunk
Component: Themes Keywords: has-patch
Focuses: Cc:

Description

Fixes a potential bug when calling themes_api( 'query_themes' ) and a successful API response is not received.

Change History (4)

This ticket was mentioned in PR #1571 on WordPress/wordpress-develop by pierlon.


3 months ago

  • Keywords has-patch added

Calling themes_api( 'query_themes' ) may not result in a successful API response and so a WP_Error is intended to be returned, but right before it is there is this block of code:

https://github.com/WordPress/wordpress-develop/blob/9b565f7907ca1d4cb32eccc980de98683758df17/src/wp-admin/includes/theme.php#L606-L615

This block of code should not be executed if $res is a WP_Error, which this PR fixes.

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

#2 @SergeyBiryukov
3 months ago

  • Component changed from General to Themes
  • Milestone changed from Awaiting Review to 5.9

#3 @SergeyBiryukov
3 months ago

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

In 51601:

Themes: Make sure the theme API response is not an error before operating on it in themes_api().

This fixes a potential bug and avoids PHP warnings when themes_api( 'query_themes' ) is called and a successful API response is not received.

Follow-up to [42632].

Props pierlo.
Fixes #53913.

Note: See TracTickets for help on using tickets.