diff --git a/ChangeLog b/ChangeLog index 88ded9672b..00d3b12ae1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog ====================== 4.2.0.0 (not yet released) ++ rfe #1483 Export Server/Database/Table without triggers + rfe #1662 Add table comment tool tip in database structure page + rfe #1447 Single table for display Character Sets and Collations + rfe #1455 Display icons/text/both for the table row actions diff --git a/export.php b/export.php index 1686030b7d..d263426ecc 100644 --- a/export.php +++ b/export.php @@ -107,6 +107,7 @@ if (!defined('TESTSUITE')) { 'sql_drop_table', 'sql_procedure_function', 'sql_create_table_statements', + 'sql_create_trigger', 'sql_if_not_exists', 'sql_auto_increment', 'sql_backquotes', diff --git a/libraries/config.default.php b/libraries/config.default.php index 2edef674c2..ae91b42a72 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -1820,6 +1820,13 @@ $cfg['Export']['sql_if_not_exists'] = true; */ $cfg['Export']['sql_procedure_function'] = true; +/** + * + * + * @global boolean $cfg['Export']['sql_create_trigger'] + */ +$cfg['Export']['sql_create_trigger'] = true; + /** * * diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index 3b81f24968..47ec21d2ab 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -170,7 +170,9 @@ $strConfigExport_sql_disable_fk_name = __('Disable foreign key checks'); $strConfigExport_sql_views_as_tables_name = __('Export views as tables'); $strConfigExport_sql_drop_database_name = sprintf(__('Add %s'), 'DROP DATABASE'); $strConfigExport_sql_drop_table_name - = sprintf(__('Add %s'), 'DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT'); + = sprintf(__('Add %s'), 'DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER'); +$strConfigExport_sql_create_trigger_name + = sprintf(__('Add %s'), 'CREATE TRIGGER'); $strConfigExport_sql_hex_for_blob_name = __('Use hexadecimal for BLOB'); $strConfigExport_sql_if_not_exists_name = sprintf(__('Add %s'), 'IF NOT EXISTS'); $strConfigExport_sql_ignore_name = __('Use ignore inserts'); diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php index a19f70d859..545cdc1412 100644 --- a/libraries/config/setup.forms.php +++ b/libraries/config/setup.forms.php @@ -301,6 +301,7 @@ $forms['Export']['Sql'] = array('Export' => array( ':group:' . __('Structure'), 'sql_drop_table', 'sql_procedure_function', + 'sql_create_trigger', 'sql_create_table_statements' => ':group', 'sql_if_not_exists', 'sql_auto_increment', diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php index e97bd34df9..4c088fd7f6 100644 --- a/libraries/config/user_preferences.forms.php +++ b/libraries/config/user_preferences.forms.php @@ -200,6 +200,7 @@ $forms['Export']['Sql'] = array( ':group:' . __('Structure'), 'Export/sql_drop_table', 'Export/sql_procedure_function', + 'Export/sql_create_trigger', 'Export/sql_create_table_statements' => ':group', 'Export/sql_if_not_exists', 'Export/sql_auto_increment', diff --git a/libraries/export.lib.php b/libraries/export.lib.php index 38d905c13f..5f8d733a98 100644 --- a/libraries/export.lib.php +++ b/libraries/export.lib.php @@ -555,8 +555,8 @@ function PMA_exportDatabase( } // now export the triggers (needs to be done after the data because // triggers can modify already imported tables) - if ($whatStrucOrData == 'structure' - || $whatStrucOrData == 'structure_and_data' + if (isset($GLOBALS['sql_create_trigger']) && ($whatStrucOrData == 'structure' + || $whatStrucOrData == 'structure_and_data') ) { if (! $export_plugin->exportStructure( $db, $table, $crlf, $err_url, @@ -667,8 +667,8 @@ function PMA_exportTable( } // now export the triggers (needs to be done after the data because // triggers can modify already imported tables) - if ($whatStrucOrData == 'structure' - || $whatStrucOrData == 'structure_and_data' + if (isset($GLOBALS['sql_create_trigger']) && ($whatStrucOrData == 'structure' + || $whatStrucOrData == 'structure_and_data') ) { if (! $export_plugin->exportStructure( $db, $table, $crlf, $err_url, diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index c5fb70f3d3..584ff520c1 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -252,6 +252,9 @@ class ExportSql extends ExportPlugin } } } + + $drop_clause .= ' / TRIGGER'; + $leaf = new BoolPropertyItem(); $leaf->setName('drop_table'); $leaf->setText(sprintf(__('Add %s statement'), $drop_clause)); @@ -270,6 +273,14 @@ class ExportSql extends ExportPlugin ); $subgroup->addProperty($leaf); } + + // Add triggers option + $leaf = new BoolPropertyItem(); + $leaf->setName('create_trigger'); + $leaf->setText( + sprintf(__('Add %s statement'), 'CREATE TRIGGER') + ); + $subgroup->addProperty($leaf); // begin CREATE TABLE statements $subgroup_create_table = new OptionsPropertySubgroup(); @@ -1620,7 +1631,9 @@ class ExportSql extends ExportPlugin . $this->_exportComment(); $delimiter = '//'; foreach ($triggers as $trigger) { - $dump .= $trigger['drop'] . ';' . $crlf; + if (! empty($GLOBALS['sql_drop_table'])) { + $dump .= $trigger['drop'] . ';' . $crlf; + } $dump .= 'DELIMITER ' . $delimiter . $crlf; $dump .= $trigger['create']; $dump .= 'DELIMITER ;' . $crlf; diff --git a/test/classes/plugin/export/PMA_ExportSql_test.php b/test/classes/plugin/export/PMA_ExportSql_test.php index 941cbd1abf..fdcc67c026 100644 --- a/test/classes/plugin/export/PMA_ExportSql_test.php +++ b/test/classes/plugin/export/PMA_ExportSql_test.php @@ -262,9 +262,15 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase $this->assertEquals( 'Add DROP TABLE / VIEW / PROCEDURE / FUNCTION' . - ' / EVENT statement', + ' / EVENT / TRIGGER statement', $leaf->getText() ); + + $leaf = array_shift($leaves); + $this->assertInstanceOf( + 'BoolPropertyItem', + $leaf + ); $leaf = array_shift($leaves); $this->assertInstanceOf( @@ -399,7 +405,7 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase $properties = $properties[0]->getProperties(); $this->assertCount( - 3, + 4, $properties ); @@ -1647,6 +1653,9 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase unset($GLOBALS['sql_compatibility']); unset($GLOBALS['sql_backquotes']); + $GLOBALS['sql_create_trigger'] = true; + $GLOBALS['sql_drop_table'] = true; + ob_start(); $this->assertTrue( $this->object->exportStructure( @@ -1664,6 +1673,9 @@ class PMA_ExportSql_Test extends PHPUnit_Framework_TestCase "foo;\nDELIMITER //\nbarDELIMITER ;\n", $result ); + + unset($GLOBALS['sql_create_trigger']); + unset($GLOBALS['sql_drop_table']); // case 3 $GLOBALS['sql_views_as_tables'] = false;