aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install/database_update.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/install/database_update.php')
-rw-r--r--phpBB/install/database_update.php201
1 files changed, 182 insertions, 19 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 3c4a7f7027..8cd07b64c6 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -7,6 +7,10 @@
*
*/
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
define('UPDATES_TO_VERSION', '3.1.0-dev');
// Enter any version to update from to test updates. The version within the db will not be updated.
@@ -107,21 +111,37 @@ if (!defined('EXT_TABLE'))
define('EXT_TABLE', $table_prefix . 'ext');
}
-$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
-$phpbb_class_loader_ext->register();
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
-$phpbb_class_loader->register();
+$phpbb_container = new ContainerBuilder();
+$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
+$loader->load('services.yml');
+
+// We must include the DI processor class files because the class loader
+// is not yet set up
+require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
+require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
+$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
+$processor->process($phpbb_container);
+
+// Setup class loader first
+$phpbb_class_loader = $phpbb_container->get('class_loader');
+$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
// set up caching
-$cache_factory = new phpbb_cache_factory($acm_type);
-$cache = $cache_factory->get_service();
-$phpbb_class_loader_ext->set_cache($cache->get_driver());
-$phpbb_class_loader->set_cache($cache->get_driver());
+$cache = $phpbb_container->get('cache');
-$phpbb_dispatcher = new phpbb_event_dispatcher();
-$request = new phpbb_request();
-$user = new phpbb_user();
-$db = new $sql_db();
+// Instantiate some basic classes
+$phpbb_dispatcher = $phpbb_container->get('dispatcher');
+$request = $phpbb_container->get('request');
+$user = $phpbb_container->get('user');
+$auth = $phpbb_container->get('auth');
+$db = $phpbb_container->get('dbal.conn');
+
+$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
+foreach ($ids as $id)
+{
+ $processor = $phpbb_container->get($id);
+ $processor->process($phpbb_container);
+}
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function
@@ -260,7 +280,7 @@ if ($has_global && !$ga_forum_id)
</form>
<?php
_print_footer();
- exit;
+ exit_handler();
}
header('Content-type: text/html; charset=UTF-8');
@@ -597,7 +617,7 @@ function _print_footer()
</div>
<div id="page-footer">
- Powered by <a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group
+ Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group
</div>
</div>
@@ -683,12 +703,12 @@ function _write_result($no_updates, $errored, $error_ary)
function _add_modules($modules_to_install)
{
- global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager;
+ global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config;
// modules require an extension manager
if (empty($phpbb_extension_manager))
{
- $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx");
+ $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx");
}
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
@@ -1027,7 +1047,7 @@ function database_update_info()
// this column was removed from the database updater
// after 3.0.9-RC3 was released. It might still exist
// in 3.0.9-RCX installations and has to be dropped in
- // 3.0.11 after the db_tools class is capable of properly
+ // 3.0.12 after the db_tools class is capable of properly
// removing a primary key.
// 'attempt_id' => array('UINT', NULL, 'auto_increment'),
'attempt_ip' => array('VCHAR:40', ''),
@@ -1071,8 +1091,20 @@ function database_update_info()
'3.0.10-RC3' => array(),
// No changes from 3.0.10 to 3.0.11-RC1
'3.0.10' => array(),
+ // Changes from 3.0.11-RC1 to 3.0.11-RC2
+ '3.0.11-RC1' => array(
+ 'add_columns' => array(
+ PROFILE_FIELDS_TABLE => array(
+ 'field_show_novalue' => array('BOOL', 0),
+ ),
+ ),
+ ),
+ // No changes from 3.0.11-RC2 to 3.0.11
+ '3.0.11-RC2' => array(),
+ // No changes from 3.0.11 to 3.0.12-RC1
+ '3.0.11' => array(),
- /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.11-RC1 */
+ /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */
// Changes from 3.1.0-dev to 3.1.0-A1
'3.1.0-dev' => array(
@@ -1111,6 +1143,9 @@ function database_update_info()
GROUPS_TABLE => array(
'group_legend' => array('UINT', 0),
),
+ USERS_TABLE => array(
+ 'user_timezone' => array('VCHAR:100', ''),
+ ),
),
),
);
@@ -1125,6 +1160,8 @@ function change_database_data(&$no_updates, $version)
{
global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx, $db_tools;
+ $update_helpers = new phpbb_update_helpers();
+
switch ($version)
{
case '3.0.0':
@@ -1970,7 +2007,7 @@ function change_database_data(&$no_updates, $version)
'user_email' => '',
'user_lang' => $config['default_lang'],
'user_style' => $config['default_style'],
- 'user_timezone' => 0,
+ 'user_timezone' => 'UTC',
'user_dateformat' => $config['default_dateformat'],
'user_allow_massemail' => 0,
);
@@ -2166,9 +2203,65 @@ function change_database_data(&$no_updates, $version)
_sql($sql, $errored, $error_ary);
}
+ // Delete orphan private messages
+ $batch_size = 500;
+
+ $sql_array = array(
+ 'SELECT' => 'p.msg_id',
+ 'FROM' => array(
+ PRIVMSGS_TABLE => 'p',
+ ),
+ 'LEFT_JOIN' => array(
+ array(
+ 'FROM' => array(PRIVMSGS_TO_TABLE => 't'),
+ 'ON' => 'p.msg_id = t.msg_id',
+ ),
+ ),
+ 'WHERE' => 't.user_id IS NULL',
+ );
+ $sql = $db->sql_build_query('SELECT', $sql_array);
+
+ do
+ {
+ $result = $db->sql_query_limit($sql, $batch_size);
+
+ $delete_pms = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $delete_pms[] = (int) $row['msg_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (!empty($delete_pms))
+ {
+ $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $delete_pms);
+ _sql($sql, $errored, $error_ary);
+ }
+ }
+ while (sizeof($delete_pms) == $batch_size);
+
$no_updates = false;
break;
+ // No changes from 3.0.11-RC1 to 3.0.11-RC2
+ case '3.0.11-RC1':
+ break;
+
+ // No changes from 3.0.11-RC2 to 3.0.11
+ case '3.0.11-RC2':
+ break;
+
+ // Changes from 3.0.11 to 3.0.12-RC1
+ case '3.0.11':
+ $sql = 'UPDATE ' . MODULES_TABLE . '
+ SET module_auth = \'acl_u_sig\'
+ WHERE module_class = \'ucp\'
+ AND module_basename = \'profile\'
+ AND module_mode = \'signature\'';
+ _sql($sql, $errored, $error_ary);
+ break;
+
// Changes from 3.1.0-dev to 3.1.0-A1
case '3.1.0-dev':
@@ -2209,6 +2302,31 @@ function change_database_data(&$no_updates, $version)
set_config('search_type', 'phpbb_search_' . $config['search_type']);
}
+ if (!isset($config['fulltext_postgres_ts_name']))
+ {
+ set_config('fulltext_postgres_ts_name', 'simple');
+ }
+
+ if (!isset($config['fulltext_postgres_min_word_len']))
+ {
+ set_config('fulltext_postgres_min_word_len', 4);
+ }
+
+ if (!isset($config['fulltext_postgres_max_word_len']))
+ {
+ set_config('fulltext_postgres_max_word_len', 254);
+ }
+
+ if (!isset($config['fulltext_sphinx_stopwords']))
+ {
+ set_config('fulltext_sphinx_stopwords', 0);
+ }
+
+ if (!isset($config['fulltext_sphinx_indexer_mem_limit']))
+ {
+ set_config('fulltext_sphinx_indexer_mem_limit', 512);
+ }
+
if (!isset($config['load_jquery_cdn']))
{
set_config('load_jquery_cdn', 0);
@@ -2307,6 +2425,13 @@ function change_database_data(&$no_updates, $version)
'auth' => 'acl_a_styles',
'cat' => 'ACP_STYLE_MANAGEMENT',
),
+ 'autologin_keys' => array(
+ 'base' => 'ucp_profile',
+ 'class' => 'ucp',
+ 'title' => 'UCP_PROFILE_AUTOLOGIN_KEYS',
+ 'auth' => '',
+ 'cat' => 'UCP_PROFILE',
+ ),
);
_add_modules($modules_to_install);
@@ -2536,6 +2661,12 @@ function change_database_data(&$no_updates, $version)
}
}
+ // Create config value for displaying last subject on forum list
+ if (!isset($config['display_last_subject']))
+ {
+ $config->set('display_last_subject', '1');
+ }
+
$no_updates = false;
if (!isset($config['assets_version']))
@@ -2543,6 +2674,38 @@ function change_database_data(&$no_updates, $version)
$config->set('assets_version', '1');
}
+ // If the column exists, we did not yet update the users timezone
+ if ($db_tools->sql_column_exists(USERS_TABLE, 'user_dst'))
+ {
+ // Update user timezones
+ $sql = 'SELECT user_dst, user_timezone
+ FROM ' . USERS_TABLE . '
+ GROUP BY user_timezone, user_dst';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_timezone = '" . $db->sql_escape($update_helpers->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "'
+ WHERE user_timezone = '" . $db->sql_escape($row['user_timezone']) . "'
+ AND user_dst = " . (int) $row['user_dst'];
+ _sql($sql, $errored, $error_ary);
+ }
+ $db->sql_freeresult($result);
+
+ // Update board default timezone
+ set_config('board_timezone', $update_helpers->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst']));
+
+ // After we have calculated the timezones we can delete user_dst column from user table.
+ $db_tools->sql_column_remove(USERS_TABLE, 'user_dst');
+ }
+
+ if (!isset($config['site_home_url']))
+ {
+ $config->set('site_home_url', '');
+ $config->set('site_home_text', '');
+ }
+
break;
}
}