Making WordPress.org

Changeset 14774


Ignore:
Timestamp:
03/28/2026 08:10:10 PM (12 hours ago)
Author:
obenland
Message:

Theme Directory: Fix PHP warnings in the blueprint permission check and save handler.

Follow-up to [14771]. When a nonexistent theme slug is requested, the
theme data doesn't have a slug property. The permission callback and
save handler were trying to use it before checking for an error response,
triggering warnings. Check for errors first, matching the pattern already
used in the preview and review handlers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-theme-preview.php

    r14771 r14774  
    5555            ),
    5656            'permission_callback' => function( $request ) {
    57                 $theme_data    = wporg_themes_theme_information( $request['slug'] );
     57                $theme_data = wporg_themes_theme_information( $request['slug'] );
     58
     59                if ( ! empty( $theme_data->error ) ) {
     60                    return false;
     61                }
     62
    5863                $theme_package = new WPORG_Themes_Repo_Package( $theme_data->slug );
    5964
    60                 if ( ! empty( $theme_data->error ) || ! $theme_package->post_author ) {
     65                if ( ! $theme_package->post_author ) {
    6166                    return false;
    6267                }
     
    117122     */
    118123    function set_blueprint( $request ) {
    119         $theme_data    = wporg_themes_theme_information( $request['slug'] );
    120         $theme_package = new WPORG_Themes_Repo_Package( $theme_data->slug );
     124        $theme_data = wporg_themes_theme_information( $request['slug'] );
    121125
    122126        if ( ! empty( $theme_data->error ) ) {
    123127            return new WP_Error( 'error', $theme_data->error );
    124128        }
     129
     130        $theme_package = new WPORG_Themes_Repo_Package( $theme_data->slug );
    125131
    126132        // Validate the blueprint, TODO expand upon this.
Note: See TracChangeset for help on using the changeset viewer.