[wp-trac] [WordPress Trac] #32640: wp-db.php bug when activating plugin ("unexpected output" During Plugin Activation)
WordPress Trac
noreply at wordpress.org
Sun Jun 14 02:35:37 UTC 2015
#32640: wp-db.php bug when activating plugin ("unexpected output" During Plugin
Activation)
---------------------------+-----------------------------
Reporter: s1nc1tycyph3r | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: 4.2.2
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
I'm A Developer Writing my latest wordpress plugin and discovered a bug
with the /include/wp-db.php file in the latest version of wp!
upon activation of my plugin i'm developing i get the following message on
the plugin activation screen
The plugin generated 9520 characters of unexpected output during
activation. If you notice “headers already sent” messages, problems with
syndication feeds or other issues, try deactivating or removing this
plugin.
and i get the following debug errors
when using the https://wordpress.org/plugins/debug-plugin-activation-
errors/
plugin
Warning: Invalid argument supplied for foreach() in
/home/tispgu/public_html/wp-testdomain/wp-includes/wp-db.php on line 1987
Warning: Invalid argument supplied for foreach() in
/home/tispgu/public_html/wp-testdomain/wp-includes/wp-db.php on line 2020
Warning: Invalid argument supplied for foreach() in
/home/tispgu/public_html/wp-testdomain/wp-includes/wp-db.php on line 2050
Warning: Invalid argument supplied for foreach() in
/home/tispgu/public_html/wp-testdomain/wp-includes/wp-db.php on line 2593
Warning: Invalid argument supplied for foreach() in
/home/tispgu/public_html/wp-testdomain/wp-includes/wp-db.php on line 1824
Warning: array_keys() expects parameter 1 to be array, null given in
/home/tispgu/public_html/wp-testdomain/wp-includes/wp-db.php on line 1829
Warning: implode() [function.implode]: Invalid arguments passed in
/home/tispgu/public_html/wp-testdomain/wp-includes/wp-db.php on line 1829
based on this error report i was able to determine the cause and location
of the plugin activation issue to be with the /wp-includes/wp-db.php file
i was also able to resolve this bug by fixing the code in a couple of
functions within that file
here are the changes i made to the code:
function code is contained in: function _insert_replace_helper( $table,
$data, $format = null, $type = 'INSERT' )
line 1814
original code:
if ( ! in_array( strtoupper( $type ), array( 'REPLACE',
'INSERT' ) ) ) {
return false;
}
line 1814
updated code:
if ( !in_array( strtoupper( $type ), array( 'REPLACE',
'INSERT' ) ) || !is_array( $data )) {
return false;
}
function code is contained in: function delete( $table, $where,
$where_format = null )
line 1907
original code:
if ( ! is_array( $where ) ) {
return false;
}
line 1907
updated code
if (!is_array( $where ) ) {
return false;
}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32640>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list