aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2011-10-13 23:29:52 +0200
committerJoas Schilling <nickvergessen@gmx.de>2011-10-13 23:29:52 +0200
commit1df2148bf4d12405018fcbe93cdbff7b9bf4174e (patch)
tree0cacb7a78fb3f41fad448def6402bb6101951153
parentfab0ec64b383c672e91db8524a225671795d4805 (diff)
downloadforums-1df2148bf4d12405018fcbe93cdbff7b9bf4174e.tar
forums-1df2148bf4d12405018fcbe93cdbff7b9bf4174e.tar.gz
forums-1df2148bf4d12405018fcbe93cdbff7b9bf4174e.tar.bz2
forums-1df2148bf4d12405018fcbe93cdbff7b9bf4174e.tar.xz
forums-1df2148bf4d12405018fcbe93cdbff7b9bf4174e.zip
[ticket/10409] Running database_update.php multiple times breaks the update
PHPBB3-10409
-rw-r--r--phpBB/install/database_update.php85
1 files changed, 57 insertions, 28 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 18741191d8..4507e5c371 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -2090,42 +2090,68 @@ function change_database_data(&$no_updates, $version)
// Changes from 3.1.0-dev to 3.1.0-A1
case '3.1.0-dev':
- set_config('use_system_cron', 0);
-
- $sql = 'UPDATE ' . GROUPS_TABLE . '
- SET group_teampage = 1
- WHERE group_type = ' . GROUP_SPECIAL . "
- AND group_name = 'ADMINISTRATORS'";
- _sql($sql, $errored, $error_ary);
-
- $sql = 'UPDATE ' . GROUPS_TABLE . '
- SET group_teampage = 2
- WHERE group_type = ' . GROUP_SPECIAL . "
- AND group_name = 'GLOBAL_MODERATORS'";
- _sql($sql, $errored, $error_ary);
-
- set_config('legend_sort_groupname', '0');
- set_config('teampage_multiple', '1');
- set_config('teampage_forums', '1');
+ if (!isset($config['use_system_cron']))
+ {
+ set_config('use_system_cron', 0);
+ }
- $sql = 'SELECT group_id
+ $sql = 'SELECT group_teampage
FROM ' . GROUPS_TABLE . '
- WHERE group_legend = 1
- ORDER BY group_name ASC';
- $result = $db->sql_query($sql);
+ WHERE group_teampage > 0';
+ $result = $db->sql_query_limit($sql, 1);
+ $added_groups_teampage = (bool) $db->sql_fetchfield('group_teampage');
+ $db->sql_freeresult($result);
- $next_legend = 1;
- while ($row = $db->sql_fetchrow($result))
+ if (!$added_groups_teampage)
{
$sql = 'UPDATE ' . GROUPS_TABLE . '
- SET group_legend = ' . $next_legend . '
- WHERE group_id = ' . (int) $row['group_id'];
+ SET group_teampage = 1
+ WHERE group_type = ' . GROUP_SPECIAL . "
+ AND group_name = 'ADMINISTRATORS'";
+ _sql($sql, $errored, $error_ary);
+
+ $sql = 'UPDATE ' . GROUPS_TABLE . '
+ SET group_teampage = 2
+ WHERE group_type = ' . GROUP_SPECIAL . "
+ AND group_name = 'GLOBAL_MODERATORS'";
_sql($sql, $errored, $error_ary);
+ }
- $next_legend++;
+ if (!isset($config['use_system_cron']))
+ {
+ set_config('legend_sort_groupname', '0');
+ set_config('teampage_multiple', '1');
+ set_config('teampage_forums', '1');
}
+
+ $sql = 'SELECT group_legend
+ FROM ' . GROUPS_TABLE . '
+ WHERE group_teampage > 1';
+ $result = $db->sql_query_limit($sql, 1);
+ $updated_group_legend = (bool) $db->sql_fetchfield('group_teampage');
$db->sql_freeresult($result);
- unset($next_legend);
+
+ if (!$updated_group_legend)
+ {
+ $sql = 'SELECT group_id
+ FROM ' . GROUPS_TABLE . '
+ WHERE group_legend = 1
+ ORDER BY group_name ASC';
+ $result = $db->sql_query($sql);
+
+ $next_legend = 1;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql = 'UPDATE ' . GROUPS_TABLE . '
+ SET group_legend = ' . $next_legend . '
+ WHERE group_id = ' . (int) $row['group_id'];
+ _sql($sql, $errored, $error_ary);
+
+ $next_legend++;
+ }
+ $db->sql_freeresult($result);
+ unset($next_legend);
+ }
// Install modules
$modules_to_install = array(
@@ -2229,7 +2255,10 @@ function change_database_data(&$no_updates, $version)
}
// Allow custom profile fields in pm templates
- set_config('load_cpf_pm', '0');
+ if (!isset($config['load_cpf_pm']))
+ {
+ set_config('load_cpf_pm', '0');
+ }
$no_updates = false;
break;