Make WordPress Core

Opened 4 months ago

Closed 8 weeks ago

#60065 closed defect (bug) (duplicate)

Update Icons Retrieval in update-core.php for Plugin Updates

Reported by: tomsnunes's profile tomsnunes Owned by: tomsnunes's profile tomsnunes
Milestone: Priority: normal
Severity: normal Version: 6.4.2
Component: Upgrade/Install Keywords:
Focuses: Cc:


WordPress version 6.4.2 seems to have a bug that is not allowing plugins to be listed on wp-admin/update-core.php page.

Apache Error Log

[proxy_fcgi:error] [pid 470:tid 140131151341120] [client 2804:90:4000:f275:4145:c03f:530:4536:0] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Cannot use object of type stdClass as array in /var/www/site/wordpress/wp-admin/update-core.php:520\nStack trace:\n#0 /var/www/site/wordpress/wp-admin/update-core.php(1118): list_plugin_updates()\n#1 {main}\n  thrown in /var/www/site/wordpress/wp-admin/update-core.php on line 520', referer: https://site/wp-admin/update-core.php

The error message indicates that there is an issue in the update-core.php file at line 520. The specific error is "Cannot use object of type stdClass as array." This suggests that there is an attempt to use an object as if it were an array on that line.

Looking at the provided code snippet, the relevant part is:

$plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );

Here, $plugin_data is being cast to an object using (object).

Later in the code, you are trying to access properties of $plugin_data as if it were an array:

$icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />';

If update is supposed to be an array and not an object, you might want to adjust how $plugin_data is handled.

Here's a modified version that assumes $plugin_data->update is an array:

$plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );

$icon            = '<span class="dashicons dashicons-admin-plugins"></span>';
$preferred_icons = array( 'svg', '2x', '1x', 'default' );

// Assuming $plugin_data->update is an array
$update_icons = (array) $plugin_data->update;

foreach ( $preferred_icons as $preferred_icon ) {
    if ( ! empty( $update_icons[ $preferred_icon ] ) ) {
        $icon = '<img src="' . esc_url( $update_icons[ $preferred_icon ] ) . '" alt="" />';

This modification ensures that $plugin_data->update is cast to an array before trying to access its elements.

Change History (2)

#1 @sabernhardt
4 months ago

  • Component changed from General to Upgrade/Install
  • Keywords has-patch has-dev-note needs-testing removed

#2 @costdev
8 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Severity changed from major to normal
  • Status changed from assigned to closed

Hi @tomsnunes, welcome to Trac and thanks for opening this ticket!

We have a discussion about this in #56431. Let's continue the discussion there. 🙂

Note: See TracTickets for help on using tickets.