Skip to content

Commit

Permalink
Don't allow to truncate empty tables in database structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetx committed Apr 20, 2012
1 parent 72663d0 commit c23fc1e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions db_structure.php
Expand Up @@ -356,22 +356,23 @@
$browse_table_label = '<a href="sql.php?' . $tbl_url_query . '&amp;pos=0">' . $truename . '</a>';

if (! $db_is_information_schema) {
$empty_table = '<a ';
if ($GLOBALS['cfg']['AjaxEnable']) {
$empty_table .= 'class="truncate_table_anchor"';
}
$empty_table .= ' href="sql.php?' . $tbl_url_query
. '&amp;sql_query=';
$empty_table .= urlencode('TRUNCATE ' . PMA_backquote($each_table['TABLE_NAME']))
. '&amp;message_to_show='
. urlencode(sprintf(__('Table %s has been emptied'), htmlspecialchars($each_table['TABLE_NAME'])))
.'">';
if ($may_have_rows) {
$empty_table = '<a ';
if ($GLOBALS['cfg']['AjaxEnable']) {
$empty_table .= 'class="truncate_table_anchor"';
}
$empty_table .= ' href="sql.php?' . $tbl_url_query
. '&amp;sql_query=';
$empty_table .= urlencode('TRUNCATE ' . PMA_backquote($each_table['TABLE_NAME']))
. '&amp;message_to_show='
. urlencode(sprintf(__('Table %s has been emptied'), htmlspecialchars($each_table['TABLE_NAME'])))
.'">';

$empty_table .= $titles['Empty'];
$empty_table .= '</a>';
} else {
$empty_table .= $titles['NoEmpty'];
$empty_table = $titles['NoEmpty'];
}
$empty_table .= '</a>';
// truncating views doesn't work
if ($table_is_view) {
$empty_table = '&nbsp;';
Expand Down

1 comment on commit c23fc1e

@roccivic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truncating empty tables should be allowed. This is because someone could have inserted some rows in a different browser tab.
Please revert this commit.

Please sign in to comment.