Make WordPress Core


Ignore:
Timestamp:
02/28/2024 06:02:09 PM (17 months ago)
Author:
costdev
Message:

Plugin Dependencies: Don't assume API response has a slug property.

Previously, WP_Plugin_Dependencies::get_dependency_api_data() attempted to set an array key using the slug property returned in a Plugins API response. However, the Plugins API response is filterable and may not contain a slug property.

Earlier in the method, a local $slug variable is used as a key for the same array.

For safety and consistency, this replaces array key references to $information->slug with $slug.

Follow-up to [57545].

Props pbiron, afragen, swissspidy, costdev.
Fixes #60540.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-plugin-dependencies.php

    r57658 r57736  
    695695            self::$dependency_api_data[ $slug ] = (array) $information;
    696696            // plugins_api() returns 'name' not 'Name'.
    697             self::$dependency_api_data[ $information->slug ]['Name'] = self::$dependency_api_data[ $information->slug ]['name'];
     697            self::$dependency_api_data[ $slug ]['Name'] = self::$dependency_api_data[ $slug ]['name'];
    698698            set_site_transient( 'wp_plugin_dependencies_plugin_data', self::$dependency_api_data, 0 );
    699699        }
Note: See TracChangeset for help on using the changeset viewer.