[wp-trac] [WordPress Trac] #34052: Plugin-Install/Update Sections
WordPress Trac
noreply at wordpress.org
Mon Sep 28 08:16:48 UTC 2015
#34052: Plugin-Install/Update Sections
----------------------------+-----------------------------
Reporter: floriansimeth | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 4.3.1
Severity: normal | Keywords:
Focuses: administration |
----------------------------+-----------------------------
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
[https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-admin/includes
/plugin-install.php#L395 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
[https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-admin/includes
/plugin-install.php#L408 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;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34052>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list