mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
allow correct updates from *-dev versions
something i have seen there, there is an open TODO for the form token (min time) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8483 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
f3d7a351a2
commit
daa2afbe36
1 changed files with 422 additions and 393 deletions
|
@ -1082,16 +1082,23 @@ if ($exit)
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
// We go through the schema changes from the lowest to the highest version
|
// We go through the schema changes from the lowest to the highest version
|
||||||
// We skip those versions older than the current version
|
// We try to also include versions 'in-between'...
|
||||||
$no_updates = true;
|
$no_updates = true;
|
||||||
foreach ($database_update_info as $version => $schema_changes)
|
$versions = array_keys($database_update_info);
|
||||||
|
for ($i = 0; $i < sizeof($versions); $i++)
|
||||||
{
|
{
|
||||||
if (version_compare($version, $current_version, '<'))
|
$version = $versions[$i];
|
||||||
|
$schema_changes = $database_update_info[$version];
|
||||||
|
|
||||||
|
$next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version;
|
||||||
|
|
||||||
|
if (!sizeof($schema_changes))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sizeof($schema_changes))
|
// If the installed version to be updated to is < than the current version, and if the current version is >= as the version to be updated to next, we will skip the process
|
||||||
|
if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>='))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1203,13 +1210,153 @@ flush();
|
||||||
|
|
||||||
$no_updates = true;
|
$no_updates = true;
|
||||||
|
|
||||||
|
$versions = array(
|
||||||
|
'3.0.RC2', '3.0.RC3', '3.0.RC4', '3.0.RC5', '3.0.0'
|
||||||
|
);
|
||||||
|
|
||||||
// some code magic
|
// some code magic
|
||||||
if (version_compare($current_version, '3.0.RC2', '<='))
|
for ($i = 0; $i < sizeof($versions); $i++)
|
||||||
{
|
{
|
||||||
|
$version = $versions[$i];
|
||||||
|
$next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version;
|
||||||
|
|
||||||
|
// If the installed version to be updated to is < than the current version, and if the current version is >= as the version to be updated to next, we will skip the process
|
||||||
|
if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>='))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$no_updates = false;
|
||||||
|
change_database_data($version);
|
||||||
|
}
|
||||||
|
|
||||||
|
_write_result($no_updates, $errored, $error_ary);
|
||||||
|
|
||||||
|
$error_ary = array();
|
||||||
|
$errored = $no_updates = false;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<br /><br />
|
||||||
|
<h1><?php echo $lang['UPDATE_VERSION_OPTIMIZE']; ?></h1>
|
||||||
|
<br />
|
||||||
|
<p><?php echo $lang['PROGRESS']; ?> :: <strong>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
flush();
|
||||||
|
|
||||||
|
// update the version
|
||||||
|
$sql = "UPDATE " . CONFIG_TABLE . "
|
||||||
|
SET config_value = '$updates_to_version'
|
||||||
|
WHERE config_name = 'version'";
|
||||||
|
_sql($sql, $errored, $error_ary);
|
||||||
|
|
||||||
|
// Reset permissions
|
||||||
|
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||||
|
SET user_permissions = '',
|
||||||
|
user_perm_from = 0";
|
||||||
|
_sql($sql, $errored, $error_ary);
|
||||||
|
|
||||||
|
/* Optimize/vacuum analyze the tables where appropriate
|
||||||
|
// this should be done for each version in future along with
|
||||||
|
// the version number update
|
||||||
|
switch ($db->sql_layer)
|
||||||
|
{
|
||||||
|
case 'mysql':
|
||||||
|
case 'mysqli':
|
||||||
|
case 'mysql4':
|
||||||
|
$sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words';
|
||||||
|
_sql($sql, $errored, $error_ary);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'postgresql':
|
||||||
|
_sql("VACUUM ANALYZE", $errored, $error_ary);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
_write_result($no_updates, $errored, $error_ary);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<h1><?php echo $lang['UPDATE_COMPLETED']; ?></h1>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!$inline_update)
|
||||||
|
{
|
||||||
|
// Purge the cache...
|
||||||
|
$cache->purge();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<p style="color:red"><?php echo $lang['UPDATE_FILES_NOTICE']; ?></p>
|
||||||
|
|
||||||
|
<p><?php echo $lang['COMPLETE_LOGIN_TO_BOARD']; ?></p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
?>
|
||||||
|
|
||||||
|
<p><?php echo ((isset($lang['INLINE_UPDATE_SUCCESSFUL'])) ? $lang['INLINE_UPDATE_SUCCESSFUL'] : 'The database update was successful. Now you need to continue the update process.'); ?></p>
|
||||||
|
|
||||||
|
<p><a href="<?php echo append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode=update&sub=file_check&lang=$language"); ?>" class="button1"><?php echo (isset($lang['CONTINUE_UPDATE_NOW'])) ? $lang['CONTINUE_UPDATE_NOW'] : 'Continue the update process now'; ?></a></p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add database update to log
|
||||||
|
add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $updates_to_version);
|
||||||
|
|
||||||
|
// Now we purge the session table as well as all cache files
|
||||||
|
$cache->purge();
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="corners-bottom"><span></span></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="page-footer">
|
||||||
|
Powered by phpBB © 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
garbage_collection();
|
||||||
|
|
||||||
|
if (function_exists('exit_handler'))
|
||||||
|
{
|
||||||
|
exit_handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function where all data changes are executed
|
||||||
|
*/
|
||||||
|
function change_database_data($version)
|
||||||
|
{
|
||||||
|
global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path;
|
||||||
|
|
||||||
|
switch ($version)
|
||||||
|
{
|
||||||
|
case '3.0.RC2':
|
||||||
|
|
||||||
$smileys = array();
|
$smileys = array();
|
||||||
|
|
||||||
$sql = 'SELECT smiley_id, code
|
$sql = 'SELECT smiley_id, code
|
||||||
FROM ' . SMILIES_TABLE;
|
FROM ' . SMILIES_TABLE;
|
||||||
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
@ -1245,11 +1392,10 @@ if (version_compare($current_version, '3.0.RC2', '<='))
|
||||||
sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id'));
|
sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$no_updates = false;
|
break;
|
||||||
}
|
|
||||||
|
case '3.0.RC3':
|
||||||
|
|
||||||
if (version_compare($current_version, '3.0.RC3', '<='))
|
|
||||||
{
|
|
||||||
if ($map_dbms === 'postgres')
|
if ($map_dbms === 'postgres')
|
||||||
{
|
{
|
||||||
$sql = "SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));';
|
$sql = "SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));';
|
||||||
|
@ -1324,7 +1470,6 @@ if (version_compare($current_version, '3.0.RC3', '<='))
|
||||||
foreach ($index_repair_list as $new_index => $garbage)
|
foreach ($index_repair_list as $new_index => $garbage)
|
||||||
{
|
{
|
||||||
sql_create_index($map_dbms, $new_index, $bad_table, $new_index_defs[$new_index]);
|
sql_create_index($map_dbms, $new_index, $bad_table, $new_index_defs[$new_index]);
|
||||||
$no_updates = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1336,11 +1481,10 @@ if (version_compare($current_version, '3.0.RC3', '<='))
|
||||||
set_config('allow_birthdays', '1');
|
set_config('allow_birthdays', '1');
|
||||||
set_config('cron_lock', '0', true);
|
set_config('cron_lock', '0', true);
|
||||||
|
|
||||||
$no_updates = false;
|
break;
|
||||||
}
|
|
||||||
|
case '3.0.RC4':
|
||||||
|
|
||||||
if (version_compare($current_version, '3.0.RC4', '<='))
|
|
||||||
{
|
|
||||||
$update_auto_increment = array(
|
$update_auto_increment = array(
|
||||||
STYLES_TABLE => 'style_id',
|
STYLES_TABLE => 'style_id',
|
||||||
STYLES_TEMPLATE_TABLE => 'template_id',
|
STYLES_TEMPLATE_TABLE => 'template_id',
|
||||||
|
@ -1456,8 +1600,6 @@ if (version_compare($current_version, '3.0.RC4', '<='))
|
||||||
$max_id = ((int) $row['max_id']) + 1;
|
$max_id = ((int) $row['max_id']) + 1;
|
||||||
_sql("ALTER TABLE {$auto_table_name} AUTO_INCREMENT = {$max_id}", $errored, $error_ary);
|
_sql("ALTER TABLE {$auto_table_name} AUTO_INCREMENT = {$max_id}", $errored, $error_ary);
|
||||||
}
|
}
|
||||||
|
|
||||||
$no_updates = false;
|
|
||||||
}
|
}
|
||||||
else if ($map_dbms == 'postgres')
|
else if ($map_dbms == 'postgres')
|
||||||
{
|
{
|
||||||
|
@ -1536,11 +1678,10 @@ if (version_compare($current_version, '3.0.RC4', '<='))
|
||||||
set_config('ldap_port', '');
|
set_config('ldap_port', '');
|
||||||
set_config('ldap_user_filter', '');
|
set_config('ldap_user_filter', '');
|
||||||
|
|
||||||
$no_updates = false;
|
break;
|
||||||
}
|
|
||||||
|
case '3.0.RC5':
|
||||||
|
|
||||||
if (version_compare($current_version, '3.0.RC5', '<='))
|
|
||||||
{
|
|
||||||
// In case the user is having the bot mediapartner google "as is", adjust it.
|
// In case the user is having the bot mediapartner google "as is", adjust it.
|
||||||
$sql = 'UPDATE ' . BOTS_TABLE . "
|
$sql = 'UPDATE ' . BOTS_TABLE . "
|
||||||
SET bot_agent = '" . $db->sql_escape('Mediapartners-Google') . "'
|
SET bot_agent = '" . $db->sql_escape('Mediapartners-Google') . "'
|
||||||
|
@ -1570,12 +1711,10 @@ if (version_compare($current_version, '3.0.RC5', '<='))
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
$db->sql_transaction('commit');
|
||||||
|
|
||||||
$no_updates = false;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
|
case '3.0.0':
|
||||||
|
|
||||||
if (version_compare($current_version, '3.0.0', '<='))
|
|
||||||
{
|
|
||||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||||
SET topic_last_view_time = topic_last_post_time
|
SET topic_last_view_time = topic_last_post_time
|
||||||
WHERE topic_last_view_time = 0";
|
WHERE topic_last_view_time = 0";
|
||||||
|
@ -1583,6 +1722,7 @@ if (version_compare($current_version, '3.0.0', '<='))
|
||||||
|
|
||||||
// Update smiley sizes
|
// Update smiley sizes
|
||||||
$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');
|
$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');
|
||||||
|
|
||||||
foreach ($smileys as $smiley)
|
foreach ($smileys as $smiley)
|
||||||
{
|
{
|
||||||
if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley))
|
if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley))
|
||||||
|
@ -1599,120 +1739,9 @@ if (version_compare($current_version, '3.0.0', '<='))
|
||||||
|
|
||||||
// TODO: remove all form token min times
|
// TODO: remove all form token min times
|
||||||
|
|
||||||
$no_updates = false;
|
|
||||||
}
|
|
||||||
_write_result($no_updates, $errored, $error_ary);
|
|
||||||
|
|
||||||
$error_ary = array();
|
|
||||||
$errored = $no_updates = false;
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<br /><br />
|
|
||||||
<h1><?php echo $lang['UPDATE_VERSION_OPTIMIZE']; ?></h1>
|
|
||||||
<br />
|
|
||||||
<p><?php echo $lang['PROGRESS']; ?> :: <strong>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
flush();
|
|
||||||
|
|
||||||
// update the version
|
|
||||||
$sql = "UPDATE " . CONFIG_TABLE . "
|
|
||||||
SET config_value = '$updates_to_version'
|
|
||||||
WHERE config_name = 'version'";
|
|
||||||
_sql($sql, $errored, $error_ary);
|
|
||||||
|
|
||||||
// Reset permissions
|
|
||||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
|
||||||
SET user_permissions = '',
|
|
||||||
user_perm_from = 0";
|
|
||||||
_sql($sql, $errored, $error_ary);
|
|
||||||
|
|
||||||
/* Optimize/vacuum analyze the tables where appropriate
|
|
||||||
// this should be done for each version in future along with
|
|
||||||
// the version number update
|
|
||||||
switch ($db->sql_layer)
|
|
||||||
{
|
|
||||||
case 'mysql':
|
|
||||||
case 'mysqli':
|
|
||||||
case 'mysql4':
|
|
||||||
$sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words';
|
|
||||||
_sql($sql, $errored, $error_ary);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'postgresql':
|
|
||||||
_sql("VACUUM ANALYZE", $errored, $error_ary);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
_write_result($no_updates, $errored, $error_ary);
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<br />
|
|
||||||
<h1><?php echo $lang['UPDATE_COMPLETED']; ?></h1>
|
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
if (!$inline_update)
|
|
||||||
{
|
|
||||||
// Purge the cache...
|
|
||||||
$cache->purge();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<p style="color:red"><?php echo $lang['UPDATE_FILES_NOTICE']; ?></p>
|
|
||||||
|
|
||||||
<p><?php echo $lang['COMPLETE_LOGIN_TO_BOARD']; ?></p>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
|
|
||||||
<p><?php echo ((isset($lang['INLINE_UPDATE_SUCCESSFUL'])) ? $lang['INLINE_UPDATE_SUCCESSFUL'] : 'The database update was successful. Now you need to continue the update process.'); ?></p>
|
|
||||||
|
|
||||||
<p><a href="<?php echo append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode=update&sub=file_check&lang=$language"); ?>" class="button1"><?php echo (isset($lang['CONTINUE_UPDATE_NOW'])) ? $lang['CONTINUE_UPDATE_NOW'] : 'Continue the update process now'; ?></a></p>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add database update to log
|
|
||||||
add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $updates_to_version);
|
|
||||||
|
|
||||||
// Now we purge the session table as well as all cache files
|
|
||||||
$cache->purge();
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span class="corners-bottom"><span></span></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="page-footer">
|
|
||||||
Powered by phpBB © 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
garbage_collection();
|
|
||||||
|
|
||||||
if (function_exists('exit_handler'))
|
|
||||||
{
|
|
||||||
exit_handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for triggering an sql statement
|
* Function for triggering an sql statement
|
||||||
|
|
Loading…
Add table
Reference in a new issue