The branch, master has been updated via 6d1bd82939546f220bed6230b59db192c14441f6 (commit) via 017ca0c22d5169224b17bb94bbde7a655fbd8b88 (commit) via 97f89e63c4387029982977d8f2c1e59219eaf41c (commit) via bea61e9f480be039cb1c359e09f62d2021487b2f (commit) via 2c1970b48ba4f11790255c203d122c41783c9d01 (commit) via 2518085d237f55ccfd56dcd016dbc2c6d0cea1b6 (commit) via a521cded01be986063b7cd5dac86ea4120a0205a (commit) via 5674ac7c3eee58ab03c745e469451c67d21a780e (commit) from 31cf332809f43c2e14b6e5771b2050567607e456 (commit)
- Log ----------------------------------------------------------------- commit 6d1bd82939546f220bed6230b59db192c14441f6 Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:42:07 2011 +0200
Factor out error message formatting
commit 017ca0c22d5169224b17bb94bbde7a655fbd8b88 Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:37:30 2011 +0200
Coding style improvements
commit 97f89e63c4387029982977d8f2c1e59219eaf41c Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:34:52 2011 +0200
Coding style improvements
commit bea61e9f480be039cb1c359e09f62d2021487b2f Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:28:18 2011 +0200
Coding style
commit 2c1970b48ba4f11790255c203d122c41783c9d01 Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:25:16 2011 +0200
Fix package
commit 2518085d237f55ccfd56dcd016dbc2c6d0cea1b6 Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:25:12 2011 +0200
Wrap long line
commit a521cded01be986063b7cd5dac86ea4120a0205a Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:20:35 2011 +0200
Remove commented out code
commit 5674ac7c3eee58ab03c745e469451c67d21a780e Author: Michal Čihař mcihar@suse.cz Date: Mon Oct 24 17:20:16 2011 +0200
Remove commented out code
-----------------------------------------------------------------------
Summary of changes: libraries/config/FormDisplay.class.php | 24 +++++-- libraries/database_interface.lib.php | 38 +++++++++ libraries/dbi/drizzle.dbi.lib.php | 73 +++++++++++------- libraries/dbi/mysql.dbi.lib.php | 23 +------ libraries/dbi/mysqli.dbi.lib.php | 131 ++++++++++++++++++++++++-------- tbl_printview.php | 4 - themes/original/layout.inc.php | 3 +- themes/pmahomme/layout.inc.php | 3 +- 8 files changed, 203 insertions(+), 96 deletions(-)
diff --git a/libraries/config/FormDisplay.class.php b/libraries/config/FormDisplay.class.php index e3010fc..3b217dd 100644 --- a/libraries/config/FormDisplay.class.php +++ b/libraries/config/FormDisplay.class.php @@ -5,7 +5,8 @@ * * Explanation of used terms: * o work_path - original field path, eg. Servers/4/verbose - * o system_path - work_path modified so that it points to the first server, eg. Servers/1/verbose + * o system_path - work_path modified so that it points to the first server, + * eg. Servers/1/verbose * o translated_path - work_path modified for HTML field name, a path with * slashes changed to hyphens, eg. Servers-4-verbose * @@ -21,7 +22,6 @@ require_once './libraries/js_escape.lib.php';
/** * Form management class, displays and processes forms - * @package phpMyAdmin-setup */ class FormDisplay { @@ -221,8 +221,12 @@ class FormDisplay : ''; $form_errors = isset($this->errors[$form->name]) ? $this->errors[$form->name] : null; - display_fieldset_top(PMA_lang("Form_$form->name"), - $form_desc, $form_errors, array('id' => $form->name)); + display_fieldset_top( + PMA_lang("Form_$form->name"), + $form_desc, + $form_errors, + array('id' => $form->name) + );
foreach ($form->fields as $field => $path) { $work_path = array_search($path, $this->system_paths); @@ -233,8 +237,16 @@ class FormDisplay ? !isset($this->userprefs_disallow[$path]) : null; // display input - $this->_displayFieldInput($form, $field, $path, $work_path, - $translated_path, $show_restore_default, $userprefs_allow, $js_default); + $this->_displayFieldInput( + $form, + $field, + $path, + $work_path, + $translated_path, + $show_restore_default, + $userprefs_allow, + $js_default + ); // register JS validators for this field if (isset($validators[$path])) { js_validate($translated_path, $validators[$path], $js); diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 921ba90..4462493 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -1653,6 +1653,44 @@ function PMA_DBI_get_triggers($db, $table = '', $delimiter = '//') }
/** + * Formats database error message in a friendly way. + * This is needed because some errors messages cannot + * be obtained by mysql_error(). + * + * @param int $error_number Error code + * @param string $error_message Error message as returned by server + * + * @return string HML text with error details + */ +function PMA_DBI_formatError($error_number, $error_message) +{ + if (! empty($error_message)) { + $error_message = PMA_DBI_convert_message($error_message); + } + + $error_message = htmlspecialchars($error_message); + + $error = '#' . ((string) $error_number); + + if ($error_number == 2002) { + $error .= ' - ' . __('The server is not responding') . ' ' . __('(or the local MySQL server's socket is not correctly configured)'); + } elseif ($error_number == 2003) { + $error .= ' - ' . __('The server is not responding'); + } elseif ($error_number == 1005) { + /* InnoDB contraints, see + * http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html + */ + $error .= ' - ' . $error_message . + ' (<a href="server_engines.php' . PMA_generate_common_url(array('engine' => 'InnoDB', 'page' => 'Status')). + '">' . __('Details...') . '</a>)'; + } else { + $error .= ' - ' . $error_message; + } + + return $error; +} + +/** * Checks whether given schema is a system schema: information_schema (MySQL and Drizzle) * or data_dictionary (Drizzle) * diff --git a/libraries/dbi/drizzle.dbi.lib.php b/libraries/dbi/drizzle.dbi.lib.php index 153c64d..668d0cb 100644 --- a/libraries/dbi/drizzle.dbi.lib.php +++ b/libraries/dbi/drizzle.dbi.lib.php @@ -334,18 +334,7 @@ function PMA_DBI_getError($link = null) // keep the error number for further check after the call to PMA_DBI_getError() $GLOBALS['errno'] = $error_number;
- if (! empty($error_message)) { - $error_message = PMA_DBI_convert_message($error_message); - } - - $error_message = htmlspecialchars($error_message); - - if ($error_number == 2002) { - $error = '#' . ((string) $error_number) . ' - ' . __('The server is not responding') . ' ' . __('(or the local Drizzle server's socket is not correctly configured)'); - } else { - $error = '#' . ((string) $error_number) . ' - ' . $error_message; - } - return $error; + return PMA_DBI_formatError($error_number, $error_message); }
/** @@ -557,27 +546,57 @@ function PMA_DBI_field_flags($result, $i) $charsetnr = $f->charset(); $f = $f->flags(); $flags = ''; - if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) { $flags .= 'unique '; } - if ($f & DRIZZLE_COLUMN_FLAGS_NUM) { $flags .= 'num '; } - if ($f & DRIZZLE_COLUMN_FLAGS_PART_KEY) { $flags .= 'part_key '; } - if ($f & DRIZZLE_COLUMN_FLAGS_SET) { $flags .= 'set '; } - if ($f & DRIZZLE_COLUMN_FLAGS_TIMESTAMP) { $flags .= 'timestamp '; } - if ($f & DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT) { $flags .= 'auto_increment '; } - if ($f & DRIZZLE_COLUMN_FLAGS_ENUM) { $flags .= 'enum '; } + if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) { + $flags .= 'unique '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_NUM) { + $flags .= 'num '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_PART_KEY) { + $flags .= 'part_key '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_SET) { + $flags .= 'set '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_TIMESTAMP) { + $flags .= 'timestamp '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT) { + $flags .= 'auto_increment '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_ENUM) { + $flags .= 'enum '; + } // See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html: // to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG // but instead the charsetnr member of the MYSQL_FIELD // structure. Watch out: some types like DATE returns 63 in charsetnr // so we have to check also the type. // Unfortunately there is no equivalent in the mysql extension. - if (($type == DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB || $type == DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR) && 63 == $charsetnr) { $flags .= 'binary ';} - if ($f & DRIZZLE_COLUMN_FLAGS_ZEROFILL) { $flags .= 'zerofill ';} - if ($f & DRIZZLE_COLUMN_FLAGS_UNSIGNED) { $flags .= 'unsigned ';} - if ($f & DRIZZLE_COLUMN_FLAGS_BLOB) { $flags .= 'blob ';} - if ($f & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY) { $flags .= 'multiple_key ';} - if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) { $flags .= 'unique_key ';} - if ($f & DRIZZLE_COLUMN_FLAGS_PRI_KEY) { $flags .= 'primary_key ';} - if ($f & DRIZZLE_COLUMN_FLAGS_NOT_NULL) { $flags .= 'not_null ';} + if (($type == DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB || $type == DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR) && 63 == $charsetnr) { + $flags .= 'binary '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_ZEROFILL) { + $flags .= 'zerofill '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_UNSIGNED) { + $flags .= 'unsigned '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_BLOB) { + $flags .= 'blob '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY) { + $flags .= 'multiple_key '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) { + $flags .= 'unique_key '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_PRI_KEY) { + $flags .= 'primary_key '; + } + if ($f & DRIZZLE_COLUMN_FLAGS_NOT_NULL) { + $flags .= 'not_null '; + } return trim($flags); }
diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index 57cb7ff..13a6136 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -340,28 +340,7 @@ function PMA_DBI_getError($link = null) // keep the error number for further check after the call to PMA_DBI_getError() $GLOBALS['errno'] = $error_number;
- if (! empty($error_message)) { - $error_message = PMA_DBI_convert_message($error_message); - } - - $error_message = htmlspecialchars($error_message); - - // Some errors messages cannot be obtained by mysql_error() - if ($error_number == 2002) { - $error = '#' . ((string) $error_number) . ' - ' . __('The server is not responding') . ' ' . __('(or the local MySQL server's socket is not correctly configured)'); - } elseif ($error_number == 2003) { - $error = '#' . ((string) $error_number) . ' - ' . __('The server is not responding'); - } elseif ($error_number == 1005) { - /* InnoDB contraints, see - * http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html - */ - $error = '#' . ((string) $error_number) . ' - ' . $error_message . - ' (<a href="server_engines.php' . PMA_generate_common_url(array('engine' => 'InnoDB', 'page' => 'Status')). - '">' . __('Details...') . '</a>)'; - } else { - $error = '#' . ((string) $error_number) . ' - ' . $error_message; - } - return $error; + return PMA_DBI_formatError($error_number, $error_message); }
/** diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index fa01497..0355961 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -70,9 +70,26 @@ function PMA_DBI_real_connect($link, $host, $user, $password, $dbname, $server_p $host = 'p:' . $host; } if ($client_flags === null) { - return @mysqli_real_connect($link, $host, $user, $password, $dbname, $server_port, $server_socket); + return @mysqli_real_connect( + $link, + $host, + $user, + $password, + $dbname, + $server_port, + $server_socket + ); } else { - return @mysqli_real_connect($link, $host, $user, $password, $dbname, $server_port, $server_socket, $client_flags); + return @mysqli_real_connect( + $link, + $host, + $user, + $password, + $dbname, + $server_port, + $server_socket, + $client_flags + ); } }
@@ -128,18 +145,47 @@ function PMA_DBI_connect($user, $password, $is_controluser = false, $server = nu }
if (!$server) { - $return_value = @PMA_DBI_real_connect($link, $cfg['Server']['host'], $user, $password, false, $server_port, $server_socket, $client_flags); + $return_value = @PMA_DBI_real_connect( + $link, + $cfg['Server']['host'], + $user, + $password, + false, + $server_port, + $server_socket, + $client_flags + ); // Retry with empty password if we're allowed to if ($return_value == false && isset($cfg['Server']['nopassword']) && $cfg['Server']['nopassword'] && !$is_controluser) { - $return_value = @PMA_DBI_real_connect($link, $cfg['Server']['host'], $user, '', false, $server_port, $server_socket, $client_flags); + $return_value = @PMA_DBI_real_connect( + $link, + $cfg['Server']['host'], + $user, + '', + false, + $server_port, + $server_socket, + $client_flags + ); } } else { - $return_value = @PMA_DBI_real_connect($link, $server['host'], $user, $password, false, $server_port, $server_socket); + $return_value = @PMA_DBI_real_connect( + $link, + $server['host'], + $user, + $password, + false, + $server_port, + $server_socket + ); }
if ($return_value == false) { if ($is_controluser) { - trigger_error(__('Connection for controluser as defined in your configuration failed.'), E_USER_WARNING); + trigger_error( + __('Connection for controluser as defined in your configuration failed.'), + E_USER_WARNING + ); return false; } // we could be calling PMA_DBI_connect() to connect to another @@ -374,18 +420,7 @@ function PMA_DBI_getError($link = null) // keep the error number for further check after the call to PMA_DBI_getError() $GLOBALS['errno'] = $error_number;
- if (! empty($error_message)) { - $error_message = PMA_DBI_convert_message($error_message); - } - - $error_message = htmlspecialchars($error_message); - - if ($error_number == 2002) { - $error = '#' . ((string) $error_number) . ' - ' . __('The server is not responding') . ' ' . __('(or the local MySQL server's socket is not correctly configured)'); - } else { - $error = '#' . ((string) $error_number) . ' - ' . $error_message; - } - return $error; + return PMA_DBI_formatError($error_number, $error_message); }
/** @@ -584,27 +619,57 @@ function PMA_DBI_field_flags($result, $i) $charsetnr = $f->charsetnr; $f = $f->flags; $flags = ''; - if ($f & MYSQLI_UNIQUE_KEY_FLAG) { $flags .= 'unique ';} - if ($f & MYSQLI_NUM_FLAG) { $flags .= 'num ';} - if ($f & MYSQLI_PART_KEY_FLAG) { $flags .= 'part_key ';} - if ($f & MYSQLI_SET_FLAG) { $flags .= 'set ';} - if ($f & MYSQLI_TIMESTAMP_FLAG) { $flags .= 'timestamp ';} - if ($f & MYSQLI_AUTO_INCREMENT_FLAG) { $flags .= 'auto_increment ';} - if ($f & MYSQLI_ENUM_FLAG) { $flags .= 'enum ';} + if ($f & MYSQLI_UNIQUE_KEY_FLAG) { + $flags .= 'unique '; + } + if ($f & MYSQLI_NUM_FLAG) { + $flags .= 'num '; + } + if ($f & MYSQLI_PART_KEY_FLAG) { + $flags .= 'part_key '; + } + if ($f & MYSQLI_SET_FLAG) { + $flags .= 'set '; + } + if ($f & MYSQLI_TIMESTAMP_FLAG) { + $flags .= 'timestamp '; + } + if ($f & MYSQLI_AUTO_INCREMENT_FLAG) { + $flags .= 'auto_increment '; + } + if ($f & MYSQLI_ENUM_FLAG) { + $flags .= 'enum '; + } // See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html: // to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG // but instead the charsetnr member of the MYSQL_FIELD // structure. Watch out: some types like DATE returns 63 in charsetnr // so we have to check also the type. // Unfortunately there is no equivalent in the mysql extension. - if (($type == MYSQLI_TYPE_TINY_BLOB || $type == MYSQLI_TYPE_BLOB || $type == MYSQLI_TYPE_MEDIUM_BLOB || $type == MYSQLI_TYPE_LONG_BLOB || $type == MYSQLI_TYPE_VAR_STRING || $type == MYSQLI_TYPE_STRING) && 63 == $charsetnr) { $flags .= 'binary ';} - if ($f & MYSQLI_ZEROFILL_FLAG) { $flags .= 'zerofill ';} - if ($f & MYSQLI_UNSIGNED_FLAG) { $flags .= 'unsigned ';} - if ($f & MYSQLI_BLOB_FLAG) { $flags .= 'blob ';} - if ($f & MYSQLI_MULTIPLE_KEY_FLAG) { $flags .= 'multiple_key ';} - if ($f & MYSQLI_UNIQUE_KEY_FLAG) { $flags .= 'unique_key ';} - if ($f & MYSQLI_PRI_KEY_FLAG) { $flags .= 'primary_key ';} - if ($f & MYSQLI_NOT_NULL_FLAG) { $flags .= 'not_null ';} + if (($type == MYSQLI_TYPE_TINY_BLOB || $type == MYSQLI_TYPE_BLOB || $type == MYSQLI_TYPE_MEDIUM_BLOB || $type == MYSQLI_TYPE_LONG_BLOB || $type == MYSQLI_TYPE_VAR_STRING || $type == MYSQLI_TYPE_STRING) && 63 == $charsetnr) { + $flags .= 'binary '; + } + if ($f & MYSQLI_ZEROFILL_FLAG) { + $flags .= 'zerofill '; + } + if ($f & MYSQLI_UNSIGNED_FLAG) { + $flags .= 'unsigned '; + } + if ($f & MYSQLI_BLOB_FLAG) { + $flags .= 'blob '; + } + if ($f & MYSQLI_MULTIPLE_KEY_FLAG) { + $flags .= 'multiple_key '; + } + if ($f & MYSQLI_UNIQUE_KEY_FLAG) { + $flags .= 'unique_key '; + } + if ($f & MYSQLI_PRI_KEY_FLAG) { + $flags .= 'primary_key '; + } + if ($f & MYSQLI_NOT_NULL_FLAG) { + $flags .= 'not_null '; + } return trim($flags); }
diff --git a/tbl_printview.php b/tbl_printview.php index d289d6b..b459d60 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -135,10 +135,8 @@ foreach ($the_tables as $key => $table) { <tr> <th><?php echo __('Column'); ?></th> <th><?php echo __('Type'); ?></th> - <!--<th><?php echo __('Attributes'); ?></th>--> <th><?php echo __('Null'); ?></th> <th><?php echo __('Default'); ?></th> - <!--<th><?php echo __('Extra'); ?></th>--> <?php if ($have_rel) { echo '<th>' . __('Links to') . '</th>' . "\n"; @@ -189,10 +187,8 @@ foreach ($the_tables as $key => $table) { ?> </td> <td><?php echo $type; ?><bdo dir="ltr"></bdo></td> - <!--<td><?php echo $attribute; ?></td>--> <td><?php echo (($row['Null'] == '' || $row['Null'] == 'NO') ? __('No') : __('Yes')); ?> </td> <td><?php if (isset($row['Default'])) { echo $row['Default']; } ?> </td> - <!--<td><?php echo $row['Extra']; ?> </td>--> <?php if ($have_rel) { echo ' <td>'; diff --git a/themes/original/layout.inc.php b/themes/original/layout.inc.php index f22369e..4c58d24 100644 --- a/themes/original/layout.inc.php +++ b/themes/original/layout.inc.php @@ -33,7 +33,6 @@ $GLOBALS['cfg']['MainColor'] = '#000000';
// background for the main frame $GLOBALS['cfg']['MainBackground'] = '#F5F5F5'; -//$GLOBALS['cfg']['MainBackground'] = '#F5F5F5 url(' . $_SESSION['PMA_Theme']->getImgPath() . 'vertical_line.png) repeat-y';
// foreground (text) color of the pointer in browse mode $GLOBALS['cfg']['BrowsePointerColor'] = '#000000'; @@ -114,7 +113,7 @@ $GLOBALS['cfg']['SQP']['fmtColor'] = array( /** * Chart colors */ - + $GLOBALS['cfg']['chartColor'] = array( 'gradientIntensity' => 0, // The style of the chart title. diff --git a/themes/pmahomme/layout.inc.php b/themes/pmahomme/layout.inc.php index 8ff3ebc..ca71272 100644 --- a/themes/pmahomme/layout.inc.php +++ b/themes/pmahomme/layout.inc.php @@ -35,7 +35,6 @@ $GLOBALS['cfg']['MainColor'] = '#000000';
// background for the main frame $GLOBALS['cfg']['MainBackground'] = '#F5F5F5'; -//$GLOBALS['cfg']['MainBackground'] = '#F5F5F5 url(' . $_SESSION['PMA_Theme']->getImgPath() . 'vertical_line.png) repeat-y';
// foreground (text) color of the pointer in browse mode $GLOBALS['cfg']['BrowsePointerColor'] = '#000000'; @@ -116,7 +115,7 @@ $GLOBALS['cfg']['SQP']['fmtColor'] = array( /** * Chart colors */ - + $GLOBALS['cfg']['chartColor'] = array( 'gradientIntensity' => 50, // The style of the chart title.
hooks/post-receive