Merge branch 'master' of github.com:phpmyadmin/phpmyadmin
This commit is contained in:
commit
69cb461454
@ -198,7 +198,6 @@ if ($server > 0 || count($cfg['Servers']) > 1
|
||||
'select_collation_connection',
|
||||
$collation_connection,
|
||||
true,
|
||||
4,
|
||||
true
|
||||
)
|
||||
. ' </form>' . "\n"
|
||||
|
||||
@ -36,8 +36,7 @@ if ($is_create_db_priv) {
|
||||
'db_collation',
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
5
|
||||
true
|
||||
);
|
||||
|
||||
if (! empty($dbstats)) {
|
||||
|
||||
@ -267,9 +267,19 @@ function PMA_analyzeTableColumnsArray($column, $comments_map, $timestamp_seen)
|
||||
$column['True_Type'] = preg_replace('@\(.*@s', '', $column['Type']);
|
||||
$column['len'] = preg_match('@float|double@', $column['Type']) ? 100 : -1;
|
||||
$column['Field_title'] = PMA_getColumnTitle($column, $comments_map);
|
||||
$column['is_binary'] = PMA_isColumnBinary($column);
|
||||
$column['is_blob'] = PMA_isColumnBlob($column);
|
||||
$column['is_char'] = PMA_isColumnChar($column);
|
||||
$column['is_binary'] = PMA_isColumn(
|
||||
$column,
|
||||
array('binary', 'varbinary')
|
||||
);
|
||||
$column['is_blob'] = PMA_isColumn(
|
||||
$column,
|
||||
array('blob', 'tinyblob', 'mediumblob', 'longblob')
|
||||
);
|
||||
$column['is_char'] = PMA_isColumn(
|
||||
$column,
|
||||
array('char', 'varchar')
|
||||
);
|
||||
|
||||
list($column['pma_type'], $column['wrap'], $column['first_timestamp'])
|
||||
= PMA_getEnumSetAndTimestampColumns($column, $timestamp_seen);
|
||||
|
||||
@ -296,77 +306,28 @@ function PMA_getColumnTitle($column, $comments_map)
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether the column is a binary
|
||||
* check whether the column is of a certain type
|
||||
* the goal is to ensure that types such as "enum('one','two','binary',..)"
|
||||
* or "enum('one','two','varbinary',..)" are not categorized as binary
|
||||
*
|
||||
* @param array $column description of column in given table
|
||||
* @param array $types the types to verify
|
||||
*
|
||||
* @return boolean If check to ensure types such as "enum('one','two','binary',..)"
|
||||
* or "enum('one','two','varbinary',..)" are not categorized as
|
||||
* binary.
|
||||
* @return boolean whether the column's type if one of the $types
|
||||
*/
|
||||
function PMA_isColumnBinary($column)
|
||||
function PMA_isColumn($column, $types)
|
||||
{
|
||||
/** @var PMA_String $pmaString */
|
||||
$pmaString = $GLOBALS['PMA_String'];
|
||||
|
||||
// The type column.
|
||||
// Fix for bug #3152931 'ENUM and SET cannot have "Binary" option'
|
||||
if ($pmaString->stripos($column['Type'], 'binary') === 0
|
||||
|| $pmaString->stripos($column['Type'], 'varbinary') === 0
|
||||
) {
|
||||
return stristr($column['Type'], 'binary');
|
||||
} else {
|
||||
return false;
|
||||
foreach ($types as $one_type) {
|
||||
if ($pmaString->stripos($column['Type'], $one_type) === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether the column is a blob
|
||||
*
|
||||
* @param array $column description of column in given table
|
||||
*
|
||||
* @return boolean If check to ensure types such as "enum('one','two','blob',..)"
|
||||
* or "enum('one','two','tinyblob',..)" etc. are not categorized
|
||||
* as blob.
|
||||
*/
|
||||
function PMA_isColumnBlob($column)
|
||||
{
|
||||
/** @var PMA_String $pmaString */
|
||||
$pmaString = $GLOBALS['PMA_String'];
|
||||
|
||||
if ($pmaString->stripos($column['Type'], 'blob') === 0
|
||||
|| $pmaString->stripos($column['Type'], 'tinyblob') === 0
|
||||
|| $pmaString->stripos($column['Type'], 'mediumblob') === 0
|
||||
|| $pmaString->stripos($column['Type'], 'longblob') === 0
|
||||
) {
|
||||
return stristr($column['Type'], 'blob');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check is table column char
|
||||
*
|
||||
* @param array $column description of column in given table
|
||||
*
|
||||
* @return boolean If check to ensure types such as "enum('one','two','char',..)" or
|
||||
* "enum('one','two','varchar',..)" are not categorized as char.
|
||||
*/
|
||||
function PMA_isColumnChar($column)
|
||||
{
|
||||
/** @var PMA_String $pmaString */
|
||||
$pmaString = $GLOBALS['PMA_String'];
|
||||
|
||||
if ($pmaString->stripos($column['Type'], 'char') === 0
|
||||
|| $pmaString->stripos($column['Type'], 'varchar') === 0
|
||||
) {
|
||||
return stristr($column['Type'], 'char');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Retrieve set, enum, timestamp table columns
|
||||
*
|
||||
|
||||
@ -24,8 +24,8 @@ if (! defined('PHPMYADMIN')) {
|
||||
* @return string
|
||||
*/
|
||||
function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION,
|
||||
$name = null, $id = null, $default = null, $label = true, $indent = 0,
|
||||
$submitOnChange = false, $displayUnavailable = false
|
||||
$name = null, $id = null, $default = null, $label = true,
|
||||
$submitOnChange = false
|
||||
) {
|
||||
global $mysql_charsets, $mysql_charsets_descriptions,
|
||||
$mysql_charsets_available, $mysql_collations, $mysql_collations_available;
|
||||
|
||||
@ -245,8 +245,7 @@ function PMA_getHtmlForChangeDatabaseCharset($db, $table)
|
||||
'db_collation',
|
||||
'select_db_collation',
|
||||
isset($_REQUEST['db_collation']) ? $_REQUEST['db_collation'] : '',
|
||||
false,
|
||||
3
|
||||
false
|
||||
)
|
||||
. '</fieldset>'
|
||||
. '<fieldset class="tblFooters">'
|
||||
@ -797,7 +796,7 @@ function PMA_getTableOptionFieldset($comment, $tbl_collation,
|
||||
. '<td>'
|
||||
. PMA_generateCharsetDropdownBox(
|
||||
PMA_CSDROPDOWN_COLLATION,
|
||||
'tbl_collation', null, $tbl_collation, false, 3
|
||||
'tbl_collation', null, $tbl_collation, false
|
||||
)
|
||||
. '</td>'
|
||||
. '</tr>';
|
||||
|
||||
@ -100,7 +100,7 @@ function PMA_getHtmlForTableConfigurations()
|
||||
? $_REQUEST['tbl_collation']
|
||||
: null
|
||||
),
|
||||
false, 3
|
||||
false
|
||||
)
|
||||
. '</td>'
|
||||
. '</tr>';
|
||||
|
||||
@ -135,7 +135,10 @@ $url_params = PMA_urlParamsInEditMode(
|
||||
|
||||
$has_blob_field = false;
|
||||
foreach ($table_columns as $column) {
|
||||
if (PMA_isColumnBlob($column)) {
|
||||
if (PMA_isColumn(
|
||||
$column,
|
||||
array('blob', 'tinyblob', 'mediumblob', 'longblob')
|
||||
)) {
|
||||
$has_blob_field = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -451,69 +451,57 @@ class PMA_InsertEditTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_isColumnBinary
|
||||
* Test for PMA_isColumn
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsColumnBinary()
|
||||
public function testIsColumn()
|
||||
{
|
||||
$column = array();
|
||||
$types = array('binary', 'varbinary');
|
||||
|
||||
$column['Type'] = 'binaryfoo';
|
||||
$this->assertEquals('binaryfoo', PMA_isColumnBinary($column));
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'Binaryfoo';
|
||||
$this->assertEquals('Binaryfoo', PMA_isColumnBinary($column));
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'varbinaryfoo';
|
||||
$this->assertEquals('binaryfoo', PMA_isColumnBinary($column));
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'barbinaryfoo';
|
||||
$this->assertFalse(PMA_isColumnBinary($column));
|
||||
}
|
||||
$this->assertFalse(PMA_isColumn($column, $types));
|
||||
|
||||
/**
|
||||
* Test for PMA_isColumnBlob
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsColumnBlob()
|
||||
{
|
||||
$column = array();
|
||||
$column['Type'] = 'blob';
|
||||
$this->assertEquals('blob', PMA_isColumnBlob($column));
|
||||
$types = array('char', 'varchar');
|
||||
|
||||
$column['Type'] = 'bloB';
|
||||
$this->assertEquals('bloB', PMA_isColumnBlob($column));
|
||||
|
||||
$column['Type'] = 'mediumBloB';
|
||||
$this->assertEquals('BloB', PMA_isColumnBlob($column));
|
||||
|
||||
$column['Type'] = 'tinyblobabc';
|
||||
$this->assertEquals('blobabc', PMA_isColumnBlob($column));
|
||||
|
||||
$column['Type'] = 'longblob';
|
||||
$this->assertEquals('blob', PMA_isColumnBlob($column));
|
||||
|
||||
$column['Type'] = 'foolongblobbar';
|
||||
$this->assertFalse(PMA_isColumnBlob($column));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_iscolumnchar
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsColumnChar()
|
||||
{
|
||||
$column = array();
|
||||
$column['Type'] = 'char(10)';
|
||||
$this->assertEquals('char(10)', PMA_iscolumnchar($column));
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'VarChar(20)';
|
||||
$this->assertEquals('Char(20)', PMA_iscolumnchar($column));
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'foochar';
|
||||
$this->assertFalse(PMA_iscolumnchar($column));
|
||||
$this->assertFalse(PMA_isColumn($column, $types));
|
||||
|
||||
$types = array('blob', 'tinyblob', 'mediumblob', 'longblob');
|
||||
|
||||
$column['Type'] = 'blob';
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'bloB';
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'mediumBloB';
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'tinyblobabc';
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'longblob';
|
||||
$this->assertTrue(PMA_isColumn($column, $types));
|
||||
|
||||
$column['Type'] = 'foolongblobbar';
|
||||
$this->assertFalse(PMA_isColumn($column, $types));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -284,7 +284,7 @@ class PMA_MySQL_Charsets_Test extends PHPUnit_Framework_TestCase
|
||||
$this->assertContains('title="German', $result);
|
||||
|
||||
$result = PMA_generateCharsetDropdownBox(
|
||||
2, null, "test_id", "latin1", false, 0, true, false
|
||||
2, null, "test_id", "latin1", false, true
|
||||
);
|
||||
$this->assertContains('name="character_set"', $result);
|
||||
$this->assertNotContains('Charset</option>', $result);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user