Make WordPress Core

Opened 9 years ago

Last modified 18 months ago

#34052 new defect (bug)

Plugin-Install/Update Sections

Reported by: floriansimeth's profile floriansimeth Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.3.1
Component: Plugins Keywords: has-patch dev-feedback
Focuses: administration Cc:

Description

Hey WP-Community,

I've found out that some plugins producing "Cannot use object of type stdClass as array" fatal errors when there is an update-notification and one clicks on the "View version x.x.x details" link.

After the plugin information window pops up WordPress is not able to read the sections. In most cases this is caused by external plugins, I guess. However I was confisued to see that WordPress is doing a type casting already but not everywhere needed.

Everything starts in the file wp-admin/includes/plugin-install.php on line 395. In this line the parameter "sections" from $api object is casted as an array. However a line later it's assumed that the parameter is an array already. Here is the code snippet:

foreach ( (array) $api->sections as $section_name => $content ) {
	$api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
}

The same problem appears on line 408.

Wouldn't it be better to cast the parameter before everything happends? This would also avoid to type-cast the same parameter over and over again, see attached patchfile.

$api->sections = (array) $api->sections;

Attachments (1)

plugin-install.php.patch (1.9 KB) - added by floriansimeth 9 years ago.

Download all attachments as: .zip

Change History (4)

#1 @DrewAPicture
9 years ago

  • Component changed from Administration to Plugins
  • Keywords has-patch added

#2 @DrewAPicture
9 years ago

  • Keywords dev-feedback added

I wonder if the hesitance to cast $api->sections as an array once and for all has anything to do with install_plugin_install_status() being recursive. At the very top, you can see that $api gets cast as an object on every recursion if it's an array.

Note: See TracTickets for help on using tickets.