Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sorry, wrong version checked in

  • Loading branch information...
commit 29ddb36e9ae60a9f568affa5dcba801be0891330 1 parent 55662d7
Sebastian Mendel authored
Showing with 31 additions and 97 deletions.
  1. +31 −97 libraries/common.lib.php
View
128 libraries/common.lib.php
@@ -730,88 +730,33 @@ function PMA_mysqlDie($error_message = '', $the_query = '',
// 2005-01-17 modified by mkkeck bugfix
if (substr($error_message, 1, 4) == '1062') {
// get the duplicate entry
-
- $no_duplicate_view = false;
-
+
// get table name
- if ( preg_match( '�(ALTER|UPDATE|INSERT|CREATE)[^\`]*\s\`([^\`]+)\`�iu', $the_query, $error_table = array() ) ) {
- $error_statement = $error_table[1];
- $error_table = $error_table[2];
-
- // duplicate value
- preg_match( '\'([^\']+)\'�i', $tmp_mysql_error, $duplicate_value = array() );
- $duplicate_value = $duplicate_value[1];
-
- // get fields from statement
- if ( $error_statement === 'UPDATE' ) {
- preg_match_all( '�(?:SET|,)\s*(?:\`)?([^\`]*)(?:\`)?\s*=\s*(\'|\"|\`)?([^\\2]*\\2|[^\s]+)�i', $the_query, $founds = array() );
- print_r( $founds );
- $error_fields = $founds[1];
- foreach ( $founds[2] as $value ) {
- if ( substr( $value, 0, 1 ) !== "'"
- && substr( $value, 0, 1 ) !== '"'
- && ! is_numeric( $value ) )
- {
- // value is a field name or function
- // TODO hanlde fieldname or function here
- $no_duplicate_view = true;
- } else {
- $duplicate_value = trim( $value ) . '-';
- }
- }
- unset( $founds );
- }
-
- if ( $error_statement !== 'ALTER' ) {
- // no alter statement
- // we need the fields in the affected index
- // and the statement
-
- $index_fields = array();
-
- // get fields from index
- require_once './libraries/tbl_indexes.lib.php';
-
- // get affected index number
- preg_match( '�\s([0-9]+)(?:\s|$)�', $error_message, $index_number = array() );
- $index_number = $index_number[1];
-
- // get indexes
- if (!defined('PMA_IDX_INCLUDED')) {
- $ret_keys = PMA_get_indexes( $error_table, 'db_details.php?' . PMA_generate_common_url( $db ) );
- }
-
- PMA_extract_indexes( $ret_keys, $indexes = array(),
- $indexes_info = array(), $indexes_data = array() );
-
- $array_keys = array_keys($indexes_data);
- foreach ( $indexes_data[$array_keys[$index_number]] as $index_part ) {
- foreach ( $index_part as $col_name ) {
- $index_fields[] = '`' . $col_name . '`';
- }
- }
-
- $error_fields = array_intersect( $error_fields, $index_fields );
-
- unset( $array_keys, $index_number, $indexes_data,
- $indexes_info, $indexes, $ret_keys, $index_fields );
- }
-
- $sql = '
- SELECT *
- FROM ' . PMA_backquote( $error_table ) . '
- WHERE CONCAT_WS( \'-\', ' . implode( ', ', $error_fields ) . ' )
- = \'' . PMA_sqlAddslashes( $duplicate_value ) . '\'
- ORDER BY ' . implode( ', ', $error_fields );
- unset( $error_table, $error_fields, $duplicate_value );
-
- echo ' <form method="post" action="import.php" style="padding: 0; margin: 0">' ."\n"
- .' <input type="hidden" name="sql_query" value="' . htmlentities( $sql ) . '" />' . "\n"
- .' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n"
- .' <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n"
- .' </form>' . "\n";
- unset( $sql );
- }
+ preg_match( '°ALTER\sTABLE\s\`([^\`]+)\`°iu', $the_query, $error_table = array() );
+ $error_table = $error_table[1];
+
+ // get fields
+ preg_match( '°\(([^\)]+)\)°i', $the_query, $error_fields = array() );
+ $error_fields = explode( ',', $error_fields[1] );
+
+ // duplicate value
+ preg_match( '°\'([^\']+)\'°i', $tmp_mysql_error, $duplicate_value = array() );
+ $duplicate_value = $duplicate_value[1];
+
+ $sql = '
+ SELECT *
+ FROM ' . PMA_backquote( $error_table ) . '
+ WHERE CONCAT_WS( "-", ' . implode( ', ', $error_fields ) . ' )
+ = "' . PMA_sqlAddslashes( $duplicate_value ) . '"
+ ORDER BY ' . implode( ', ', $error_fields );
+ unset( $error_table, $error_fields, $duplicate_value );
+
+ echo ' <form method="post" action="import.php" style="padding: 0; margin: 0">' ."\n"
+ .' <input type="hidden" name="sql_query" value="' . htmlentities( $sql ) . '" />' . "\n"
+ .' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n"
+ .' <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n"
+ .' </form>' . "\n";
+ unset( $sql );
} // end of show duplicate entry
echo '</div>';
@@ -1979,7 +1924,8 @@ function PMA_showMessage($message)
$tooltip .= '(' . PMA_formatNumber( $tbl_status['Rows'], 0 ) . ' ' . $GLOBALS['strRows'] . ')';
PMA_DBI_free_result($result);
$uni_tbl = PMA_jsFormat( $GLOBALS['db'] . '.' . $GLOBALS['table'], false );
- ?>
+ echo "\n";
+ ?>
<script type="text/javascript">
//<![CDATA[
window.parent.updateTableTitle( '<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFormat($tooltip, false); ?>' );
@@ -1987,7 +1933,7 @@ function PMA_showMessage($message)
</script>
<?php
} // end if
- } // end if
+ } // end if... else if
// Checks if the table needs to be repaired after a TRUNCATE query.
if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query'])
@@ -2229,18 +2175,6 @@ function PMA_showMessage($message)
if (!empty($GLOBALS['show_as_php'])) {
echo '\';';
}
-
- $warnings = PMA_DBI_get_warnings();
- if ( count( $warnings ) > 0 ) {
- echo ' <strong>' . $GLOBALS['strMySQLSaid'] . '</strong>'
- .PMA_showMySQLDocu('Error-returns', 'Error-returns');
- foreach ( $warnings as $warning ) {
- echo '<div class="' . $warning['Level'] . '">'
- .'#' . $warning['Code'] . ' - ' . $warning['Message']
- .'</div>';
- }
- }
-
echo '</fieldset>' . "\n";
if ( ! empty( $edit_target ) ) {
@@ -2642,8 +2576,8 @@ function PMA_linkOrButton($url, $message, $tag_params = array(), $new_form = TRU
. ' value="' . htmlspecialchars($message) . '" />';
} else {
$ret .= '<input type="image"' . $submit_name . ' ' . implode( ' ', $tag_params_strings )
- . ' src="' . preg_replace('^.*\ssrc="([^"]*)".*$si', '\1', $message) . '"'
- . ' value="' . htmlspecialchars(preg_replace('^.*\salt="([^"]*)".*$si', '\1', $message)) . '" />';
+ . ' src="' . preg_replace('°^.*\ssrc="([^"]*)".*$°si', '\1', $message) . '"'
+ . ' value="' . htmlspecialchars(preg_replace('°^.*\salt="([^"]*)".*$°si', '\1', $message)) . '" />';
}
} else {
$message = trim( strip_tags( $message ) );
Please sign in to comment.
Something went wrong with that request. Please try again.