diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 28670b33c3..16b4759fd7 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -132,6 +132,7 @@
[Fix] Add indicator to be used in code if session was created (user visits the site for the first time).
[Fix] Correctly count topic views for guests visiting the website the first time by entering the topic directly (Bug #43445)
[Fix] Fix bug in postgresql db layer for LIMIT ALL clauses (reported by JRSweets)
+ [Fix] Sort backups by date, newest first (Bug #14818)
[Change] Allow download of conflicting file for later reference in automatic updater
[Change] Default difference view is now 'inline' instead of 'side by side'
[Change] Added new option for merging differences to conflicting files in automatic updater
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index e2ca66b2f3..06425c4a1e 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -27,7 +27,7 @@ class acp_database
{
global $cache, $db, $user, $auth, $template, $table_prefix;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
-
+
$user->add_lang('acp/database');
$this->tpl_name = 'acp_database';
@@ -187,7 +187,7 @@ class acp_database
$template->assign_vars(array(
'U_ACTION' => $this->u_action . '&action=download'
));
-
+
$available_methods = array('gzip' => 'zlib', 'bzip2' => 'bz2');
foreach ($available_methods as $type => $module)
@@ -424,27 +424,37 @@ class acp_database
$dir = $phpbb_root_path . 'store/';
$dh = @opendir($dir);
+ $backup_files = array();
+
if ($dh)
{
while (($file = readdir($dh)) !== false)
{
if (preg_match('#^backup_(\d{10,})_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches))
{
- $supported = in_array($matches[2], $methods);
-
- if ($supported == 'true')
+ if (in_array($matches[2], $methods))
{
- $template->assign_block_vars('files', array(
- 'FILE' => $file,
- 'NAME' => gmdate("d-m-Y H:i:s", $matches[1]),
- 'SUPPORTED' => $supported
- ));
+ $backup_files[gmdate("d-m-Y H:i:s", $matches[1])] = $file;
}
}
}
closedir($dh);
}
+ if (!empty($backup_files))
+ {
+ krsort($backup_files);
+
+ foreach ($backup_files as $name => $file)
+ {
+ $template->assign_block_vars('files', array(
+ 'FILE' => $file,
+ 'NAME' => $name,
+ 'SUPPORTED' => true,
+ ));
+ }
+ }
+
$template->assign_vars(array(
'U_ACTION' => $this->u_action . '&action=submit'
));
@@ -508,7 +518,7 @@ class base_extractor
header('Pragma: no-cache');
header("Content-Type: $mimetype; name=\"$name\"");
header("Content-disposition: attachment; filename=$name");
-
+
switch ($format)
{
case 'bzip2':
@@ -527,14 +537,14 @@ class base_extractor
break;
}
}
-
+
if ($store == true)
{
global $phpbb_root_path;
$file = $phpbb_root_path . 'store/' . $filename . $ext;
-
+
$this->fp = $open($file, 'w');
-
+
if (!$this->fp)
{
trigger_error('Unable to write temporary file to storage folder', E_USER_ERROR);
@@ -662,11 +672,11 @@ class mysql_extractor extends base_extractor
if ($result != false)
{
$fields_cnt = mysqli_num_fields($result);
-
+
// Get field information
$field = mysqli_fetch_fields($result);
$field_set = array();
-
+
for ($j = 0; $j < $fields_cnt; $j++)
{
$field_set[] = $field[$j]->name;
@@ -679,7 +689,7 @@ class mysql_extractor extends base_extractor
$first_set = true;
$query_len = 0;
$max_len = get_usable_memory();
-
+
while ($row = mysqli_fetch_row($result))
{
$values = array();
@@ -750,7 +760,7 @@ class mysql_extractor extends base_extractor
$field[] = mysql_fetch_field($result, $i);
}
$field_set = array();
-
+
for ($j = 0; $j < $fields_cnt; $j++)
{
$field_set[] = $field[$j]->name;
@@ -966,7 +976,7 @@ class sqlite_extractor extends base_extractor
$ar[] = $row;
}
$db->sql_freeresult($result);
-
+
foreach ($ar as $value)
{
if (strpos($value['name'], 'autoindex') !== false)
@@ -1124,7 +1134,7 @@ class postgres_extractor extends base_extractor
$sql_data .= "CREATE SEQUENCE {$table_name}_seq;\n";
}
$db->sql_freeresult($result);
-
+
$field_query = "SELECT a.attnum, a.attname as field, t.typname as type, a.attlen as length, a.atttypmod as lengthvar, a.attnotnull as notnull
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '" . $db->sql_escape($table_name) . "'
@@ -1188,7 +1198,7 @@ class postgres_extractor extends base_extractor
{
$line .= ' NOT NULL';
}
-
+
$lines[] = $line;
}
$db->sql_freeresult($result);
@@ -1388,33 +1398,33 @@ class mssql_extractor extends base_extractor
$sql_data .= "GO\n";
$sql_data .= "\nCREATE TABLE [$table_name] (\n";
$rows = array();
-
+
$text_flag = false;
-
+
$sql = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') as IS_IDENTITY
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '$table_name'";
$result = $db->sql_query($sql);
-
+
while ($row = $db->sql_fetchrow($result))
{
$line = "\t[{$row['COLUMN_NAME']}] [{$row['DATA_TYPE']}]";
-
+
if ($row['DATA_TYPE'] == 'text')
{
$text_flag = true;
}
-
+
if ($row['IS_IDENTITY'])
{
$line .= ' IDENTITY (1 , 1)';
}
-
+
if ($row['CHARACTER_MAXIMUM_LENGTH'] && $row['DATA_TYPE'] !== 'text')
{
$line .= ' (' . $row['CHARACTER_MAXIMUM_LENGTH'] . ')';
}
-
+
if ($row['IS_NULLABLE'] == 'YES')
{
$line .= ' NULL';
@@ -1423,27 +1433,27 @@ class mssql_extractor extends base_extractor
{
$line .= ' NOT NULL';
}
-
+
if ($row['COLUMN_DEFAULT'])
{
$line .= ' DEFAULT ' . $row['COLUMN_DEFAULT'];
}
-
+
$rows[] = $line;
}
$db->sql_freeresult($result);
-
+
$sql_data .= implode(",\n", $rows);
$sql_data .= "\n) ON [PRIMARY]";
-
+
if ($text_flag)
{
$sql_data .= " TEXTIMAGE_ON [PRIMARY]";
}
-
+
$sql_data .= "\nGO\n\n";
$rows = array();
-
+
$sql = "SELECT CONSTRAINT_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = '$table_name'";
@@ -1463,7 +1473,7 @@ class mssql_extractor extends base_extractor
$sql_data .= "\n\t) ON [PRIMARY] \nGO\n";
}
$db->sql_freeresult($result);
-
+
$index = array();
$sql = "EXEC sp_statistics '$table_name'";
$result = $db->sql_query($sql);
@@ -1475,12 +1485,12 @@ class mssql_extractor extends base_extractor
}
}
$db->sql_freeresult($result);
-
+
foreach ($index as $index_name => $column_name)
{
$index[$index_name] = implode(', ', $column_name);
}
-
+
foreach ($index as $index_name => $columns)
{
$sql_data .= "\nCREATE INDEX [$index_name] ON [$table_name]($columns) ON [PRIMARY]\nGO\n";
@@ -1508,7 +1518,7 @@ class mssql_extractor extends base_extractor
$ary_type = $ary_name = array();
$ident_set = false;
$sql_data = '';
-
+
// Grab all of the data from current table.
$sql = "SELECT *
FROM $table_name";
@@ -1602,7 +1612,7 @@ class mssql_extractor extends base_extractor
$ary_type = $ary_name = array();
$ident_set = false;
$sql_data = '';
-
+
// Grab all of the data from current table.
$sql = "SELECT *
FROM $table_name";
@@ -1819,7 +1829,7 @@ class oracle_extractor extends base_extractor
{
global $db;
$ary_type = $ary_name = array();
-
+
// Grab all of the data from current table.
$sql = "SELECT *
FROM $table_name";
@@ -1915,7 +1925,7 @@ class firebird_extractor extends base_extractor
{
global $db;
$ary_type = $ary_name = array();
-
+
// Grab all of the data from current table.
$sql = "SELECT *
FROM $table_name";
@@ -2244,7 +2254,7 @@ function fgetd(&$fp, $delim, $read, $seek, $eof, $buffer = 8192)
{
$record = '';
$delim_len = strlen($delim);
-
+
while (!$eof($fp))
{
$pos = strpos($record, $delim);