From eb9a250ae836537ebc1f6b49676e95beaadf2d8e Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 29 Jul 2015 06:29:22 +0000 Subject: [PATCH] WPDB: When checking that text isn't too long to insert into a column, `LONGTEXT` columns could fail, as their length is longer than `PHP_INT_MAX`. Treating their length as a `float` instead of an `int` fixes this. Merge of [33276] to the 4.1 branch. See #32165. Built from https://develop.svn.wordpress.org/branches/4.1@33477 git-svn-id: http://core.svn.wordpress.org/branches/4.1@33444 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/wp-db.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 613f5bbb7f..d043632af9 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -2658,9 +2658,9 @@ class wpdb { // We're going to need to truncate by characters or bytes, depending on the length value we have. if ( 'byte' === $value['length']['type'] ) { // Split the CONVERT() calls by charset, so we can make sure the connection is right - $queries[ $value['charset'] ][ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING binary ), %d ) USING {$value['charset']} )", $value['value'], $value['length']['length'] ); + $queries[ $value['charset'] ][ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING binary ), %.0f ) USING {$value['charset']} )", $value['value'], $value['length']['length'] ); } else { - $queries[ $value['charset'] ][ $col ] = $this->prepare( "LEFT( CONVERT( %s USING {$value['charset']} ), %d )", $value['value'], $value['length']['length'] ); + $queries[ $value['charset'] ][ $col ] = $this->prepare( "LEFT( CONVERT( %s USING {$value['charset']} ), %.0f )", $value['value'], $value['length']['length'] ); } unset( $data[ $col ]['db'] );