From d8ef094a9a0373639089fbf52f1c844e90a95dd8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 24 May 2021 16:36:54 +0200 Subject: [PATCH 1/2] [ticket/16783] Remove structure only backup PHPBB3-16783 --- phpBB/adm/style/acp_database.html | 6 ---- phpBB/includes/acp/acp_database.php | 50 ++--------------------------- 2 files changed, 3 insertions(+), 53 deletions(-) diff --git a/phpBB/adm/style/acp_database.html b/phpBB/adm/style/acp_database.html index cb2b6d0d39..26bc563e5b 100644 --- a/phpBB/adm/style/acp_database.html +++ b/phpBB/adm/style/acp_database.html @@ -55,12 +55,6 @@
{L_BACKUP_OPTIONS} -
-
-
- -
-
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index c1c748832b..6d96d5bf8e 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -55,7 +55,6 @@ class acp_database switch ($action) { case 'download': - $type = $request->variable('type', ''); $table = array_intersect($this->db_tools->sql_list_tables(), $request->variable('table', array(''))); $format = $request->variable('method', ''); @@ -69,20 +68,6 @@ class acp_database trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } - $store = true; - $structure = false; - $schema_data = false; - - if ($type == 'full' || $type == 'structure') - { - $structure = true; - } - - if ($type == 'full' || $type == 'data') - { - $schema_data = true; - } - @set_time_limit(1200); @set_time_limit(0); @@ -92,46 +77,17 @@ class acp_database /** @var phpbb\db\extractor\extractor_interface $extractor Database extractor */ $extractor = $phpbb_container->get('dbal.extractor'); - $extractor->init_extractor($format, $filename, $time, false, $store); + $extractor->init_extractor($format, $filename, $time, false, true); $extractor->write_start($table_prefix); foreach ($table as $table_name) { // Get the table structure - if ($structure) - { - $extractor->write_table($table_name); - } - else - { - // We might wanna empty out all that junk :D - switch ($db->get_sql_layer()) - { - case 'sqlite3': - $extractor->flush('DELETE FROM ' . $table_name . ";\n"); - break; - - case 'mssql_odbc': - case 'mssqlnative': - $extractor->flush('TRUNCATE TABLE ' . $table_name . "GO\n"); - break; - - case 'oracle': - $extractor->flush('TRUNCATE TABLE ' . $table_name . "/\n"); - break; - - default: - $extractor->flush('TRUNCATE TABLE ' . $table_name . ";\n"); - break; - } - } + $extractor->write_table($table_name); // Data - if ($schema_data) - { - $extractor->write_data($table_name); - } + $extractor->write_data($table_name); } $extractor->write_end(); From acf08859483a609752b2c15a904ac69b35e87ea5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 25 May 2021 20:34:31 +0200 Subject: [PATCH 2/2] [ticket/16783] Add back data only backups PHPBB3-16783 --- phpBB/adm/style/acp_database.html | 5 +++++ phpBB/includes/acp/acp_database.php | 30 +++++++++++++++++++++++++++-- phpBB/language/en/acp/database.php | 1 - 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/phpBB/adm/style/acp_database.html b/phpBB/adm/style/acp_database.html index 26bc563e5b..b0b7c54dbb 100644 --- a/phpBB/adm/style/acp_database.html +++ b/phpBB/adm/style/acp_database.html @@ -55,6 +55,11 @@
{L_BACKUP_OPTIONS} +
+
+
+
+
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 6d96d5bf8e..e320df2117 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -55,6 +55,7 @@ class acp_database switch ($action) { case 'download': + $type = $request->variable('type', ''); $table = array_intersect($this->db_tools->sql_list_tables(), $request->variable('table', array(''))); $format = $request->variable('method', ''); @@ -84,9 +85,34 @@ class acp_database foreach ($table as $table_name) { // Get the table structure - $extractor->write_table($table_name); + if ($type == 'full') + { + $extractor->write_table($table_name); + } + else + { + // We might wanna empty out all that junk :D + switch ($db->get_sql_layer()) + { + case 'sqlite3': + $extractor->flush('DELETE FROM ' . $table_name . ";\n"); + break; - // Data + case 'mssql_odbc': + case 'mssqlnative': + $extractor->flush('TRUNCATE TABLE ' . $table_name . "GO\n"); + break; + + case 'oracle': + $extractor->flush('TRUNCATE TABLE ' . $table_name . "/\n"); + break; + + default: + $extractor->flush('TRUNCATE TABLE ' . $table_name . ";\n"); + } + } + + // Only supported types are full and data, therefore always write the data $extractor->write_data($table_name); } diff --git a/phpBB/language/en/acp/database.php b/phpBB/language/en/acp/database.php index 302aaee570..11acfe82d3 100644 --- a/phpBB/language/en/acp/database.php +++ b/phpBB/language/en/acp/database.php @@ -70,7 +70,6 @@ $lang = array_merge($lang, array( 'START_RESTORE' => 'Start restore', 'STORE_AND_DOWNLOAD' => 'Store and download', 'STORE_LOCAL' => 'Store file locally', - 'STRUCTURE_ONLY' => 'Structure only', 'TABLE_SELECT' => 'Table select', 'TABLE_SELECT_ERROR'=> 'You must select at least one table.',