Fix uncaught TypeError in Util::printableBitValue

Fixes #14718

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
Maurício Meneghini Fauth 2018-11-12 21:50:42 -02:00
parent 2d0dbca50a
commit d7affca556
6 changed files with 15 additions and 15 deletions

View File

@ -453,8 +453,8 @@ class TableSearchController extends TableController
foreach ($row as $col => $val) {
if ($fields_meta[$i]->type == 'bit') {
$row[$col] = Util::printableBitValue(
$val,
$fields_meta[$i]->length
(int) $val,
(int) $fields_meta[$i]->length
);
}
$i++;

View File

@ -4049,8 +4049,8 @@ class Results
$formatted = false;
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$column = Util::printableBitValue(
$column,
$meta->length
(int) $column,
(int) $meta->length
);
// some results of PROCEDURE ANALYSE() are reported as

View File

@ -2001,8 +2001,8 @@ class InsertEdit
$special_chars = $as_is
? $current_row[$column['Field']]
: Util::printableBitValue(
$current_row[$column['Field']],
$extracted_columnspec['spec_in_brackets']
(int) $current_row[$column['Field']],
(int) $extracted_columnspec['spec_in_brackets']
);
} elseif ((substr($column['True_Type'], 0, 9) == 'timestamp'
|| $column['True_Type'] == 'datetime'

View File

@ -2457,8 +2457,8 @@ class ExportSql extends ExportPlugin
// detection of 'bit' works only on mysqli extension
$values[] = "b'" . $GLOBALS['dbi']->escapeString(
Util::printableBitValue(
$row[$j],
$fields_meta[$j]->length
(int) $row[$j],
(int) $fields_meta[$j]->length
)
)
. "'";

View File

@ -2067,7 +2067,7 @@ class Util
}
} elseif ($meta->type == 'bit') {
$con_val = "= b'"
. self::printableBitValue($row[$i], $meta->length) . "'";
. self::printableBitValue((int) $row[$i], (int) $meta->length) . "'";
} else {
$con_val = '= \''
. $GLOBALS['dbi']->escapeString($row[$i]) . '\'';
@ -2773,12 +2773,12 @@ class Util
* function because in PHP, decbin() supports only 32 bits
* on 32-bit servers
*
* @param integer $value coming from a BIT field
* @param integer $length length
* @param int $value coming from a BIT field
* @param int $length length
*
* @return string the printable value
* @return string the printable value
*/
public static function printableBitValue($value, $length)
public static function printableBitValue(int $value, int $length): string
{
// if running on a 64-bit server or the length is safe for decbin()
if (PHP_INT_SIZE == 8 || $length < 33) {

View File

@ -1763,11 +1763,11 @@ class UtilTest extends PmaTestCase
{
return [
[
'20131009',
20131009,
64,
'0000000000000000000000000000000000000001001100110010110011000001'
],
['5', 32, '00000000000000000000000000000101']
[5, 32, '00000000000000000000000000000101']
];
}