Make WordPress Core

Changeset 57736

Timestamp:
02/28/2024 06:02:09 PM (5 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.

Location:
trunk
Files:
2 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'];
    698698            set_site_transient( 'wp_plugin_dependencies_plugin_data', self::$dependency_api_data, 0 );
    699699        }
  • trunk/tests/phpunit/tests/admin/plugin-dependencies/getDependencyData.php

    r57545 r57736  
    7171        $this->assertFalse( $actual );
    7272    }
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
    73129}
Note: See TracChangeset for help on using the changeset viewer.