[wp-trac] [WordPress Trac] #32315: $wpdb->insert fails without error msg
WordPress Trac
noreply at wordpress.org
Mon Apr 18 11:19:23 UTC 2016
#32315: $wpdb->insert fails without error msg
--------------------------+------------------------------
Reporter: dlt101 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: 4.2.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by NettSite):
The problem is here, in /includes/wp-db.php:
{{{#!php
<?php
/**
* For string fields, record the maximum string length that field can
safely save.
*
* @since 4.2.1
* @access protected
*
* @param array $data As it comes from the
wpdb::process_field_charsets() method.
* @param string $table Table name.
* @return array|false The same array as $data with additional 'length'
keys, or false if
* any of the values were too long for their
corresponding field.
*/
protected function process_field_lengths($data, $table) {
foreach ($data as $field => $value) {
if ('%d' === $value['format'] || '%f' === $value['format']) {
/*
* We can skip this field if we know it isn't a string.
* This checks %d/%f versus ! %s because its sprintf() could take
more.
*/
$value['length'] = false;
} else {
$value['length'] = $this->get_col_length($table, $field);
if (is_wp_error($value['length'])) {
return false;
}
}
$data[$field] = $value;
}
return $data;
}
}}}
This function simply returns "FALSE" if a data field is too long.
There should be some means of discovering which field is too long, e.g.
logging an error, or displaying one if WP_DEBUG is TRUE.
This would have saved me a good few hours of barking up wrong trees this
morning.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32315#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list