Merge branch 'feature/migrations-data' of github.com:EXreaction/phpbb3 into feature/migrations-data

# By Dhruv (19) and others
# Via Nathaniel Guse (3) and others
* 'feature/migrations-data' of github.com:EXreaction/phpbb3: (38 commits)
  [feature/migrations] Use the user class for language handling
  [feature/migrations] Fully revert the removal of the user_msnm field
  [feature/migrations] Revert unrelated change to schema_data.sql
  [ticket/11179] remove extra & in function call
  [ticket/11179] correct start parameter in sphinx search
  [ticket/11179] correct start parameter in native author search
  [ticket/11179] correct start parameter in native keyword search
  [ticket/11179] fix success query path for postgres
  [ticket/11179] fix success query path for mysql
  [ticket/11179] minor fixes
  [ticket/11179] pass start param by reference in postgres
  [ticket/11179] correct start param in author search of postgres
  [ticket/11179] correct start parameter in psql keyword search
  [ticket/11179] pass start param by reference in author search
  [ticket/11179] correct start parameter for author search
  [ticket/11179] use FOUND_ROWS query to re-search with changed start param
  [ticket/11179] pass start parameter by reference
  [ticket/11179] correct the start parameter while retrieving from cache
  [ticket/11179] add search query in case initial one fails
  [ticket/11359] html escape sphinx config data
  ...
This commit is contained in:
Nathaniel Guse 2013-02-25 13:12:57 -06:00
commit e632049e19
27 changed files with 440 additions and 151 deletions

View file

@ -7,7 +7,13 @@
<p>{L_EXTENSIONS_EXPLAIN}</p> <p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_ENABLE_EXPLAIN}</p> <p>{L_ENABLE_EXPLAIN}</p>
<!-- IF PRE --> <!-- IF MIGRATOR_ERROR -->
<div class="errorbox">
<p><strong>{L_MIGRATION_EXCEPTION_ERROR}</strong></p>
<p>{MIGRATOR_ERROR}</p>
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ELSEIF PRE -->
<div class="errorbox"> <div class="errorbox">
<p>{L_ENABLE_CONFIRM}</p> <p>{L_ENABLE_CONFIRM}</p>
</div> </div>

View file

@ -7,7 +7,13 @@
<p>{L_EXTENSIONS_EXPLAIN}</p> <p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_PURGE_EXPLAIN}</p> <p>{L_PURGE_EXPLAIN}</p>
<!-- IF PRE --> <!-- IF MIGRATOR_ERROR -->
<div class="errorbox">
<p><strong>{L_MIGRATION_EXCEPTION_ERROR}</strong></p>
<p>{MIGRATOR_ERROR}</p>
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ELSEIF PRE -->
<div class="errorbox"> <div class="errorbox">
<p>{L_PURGE_CONFIRM}</p> <p>{L_PURGE_CONFIRM}</p>
</div> </div>

View file

@ -112,8 +112,10 @@ services:
ext.manager: ext.manager:
class: phpbb_extension_manager class: phpbb_extension_manager
arguments: arguments:
- @service_container
- @dbal.conn - @dbal.conn
- @config - @config
- @migrator
- %tables.ext% - %tables.ext%
- %core.root_path% - %core.root_path%
- .%core.php_ext% - .%core.php_ext%

View file

@ -37,7 +37,7 @@ class acp_extensions
$this->template = $template; $this->template = $template;
$this->user = $user; $this->user = $user;
$user->add_lang(array('install', 'acp/extensions')); $user->add_lang(array('install', 'acp/extensions', 'migrator'));
$this->page_title = 'ACP_EXTENSIONS'; $this->page_title = 'ACP_EXTENSIONS';
@ -103,11 +103,18 @@ class acp_extensions
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action)); trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action));
} }
if ($phpbb_extension_manager->enable_step($ext_name)) try
{ {
$template->assign_var('S_NEXT_STEP', true); if ($phpbb_extension_manager->enable_step($ext_name))
{
$template->assign_var('S_NEXT_STEP', true);
meta_refresh(0, $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name)); meta_refresh(0, $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name));
}
}
catch (phpbb_db_migration_exception $e)
{
$template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
} }
$this->tpl_name = 'acp_ext_enable'; $this->tpl_name = 'acp_ext_enable';
@ -156,11 +163,18 @@ class acp_extensions
break; break;
case 'purge': case 'purge':
if ($phpbb_extension_manager->purge_step($ext_name)) try
{ {
$template->assign_var('S_NEXT_STEP', true); if ($phpbb_extension_manager->purge_step($ext_name))
{
$template->assign_var('S_NEXT_STEP', true);
meta_refresh(0, $this->u_action . '&amp;action=purge&amp;ext_name=' . urlencode($ext_name)); meta_refresh(0, $this->u_action . '&amp;action=purge&amp;ext_name=' . urlencode($ext_name));
}
}
catch (phpbb_db_migration_exception $e)
{
$template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
} }
$this->tpl_name = 'acp_ext_purge'; $this->tpl_name = 'acp_ext_purge';

View file

@ -303,7 +303,7 @@ class phpbb_db_tools
* @param phpbb_db_driver $db Database connection * @param phpbb_db_driver $db Database connection
* @param bool $return_statements True if only statements should be returned and no SQL being executed * @param bool $return_statements True if only statements should be returned and no SQL being executed
*/ */
function phpbb_db_tools(&$db, $return_statements = false) function phpbb_db_tools(phpbb_db_driver $db, $return_statements = false)
{ {
$this->db = $db; $this->db = $db;
$this->return_statements = $return_statements; $this->return_statements = $return_statements;

View file

@ -21,7 +21,6 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration
'phpbb_db_migration_data_310_style_update_p2', 'phpbb_db_migration_data_310_style_update_p2',
'phpbb_db_migration_data_310_timezone_p2', 'phpbb_db_migration_data_310_timezone_p2',
'phpbb_db_migration_data_310_reported_posts_display', 'phpbb_db_migration_data_310_reported_posts_display',
'phpbb_db_migration_data_310_remove_msnm',
); );
} }

View file

@ -1,43 +0,0 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_remove_msnm extends phpbb_db_migration
{
public function effectively_installed()
{
return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_msnm');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11');
}
public function update_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'users' => array(
'user_msnm',
),
),
);
}
public function revert_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'users' => array(
'user_msnm' => array('VCHAR_UNI', ''),
),
),
);
}
}

View file

@ -52,4 +52,28 @@ class phpbb_db_migration_exception extends \Exception
{ {
return $this->message . ': ' . var_export($this->parameters, true); return $this->message . ': ' . var_export($this->parameters, true);
} }
/**
* Get the parameters
*
* @return array
*/
public function getParameters()
{
return $this->parameters;
}
/**
* Get localised message (with $user->lang())
*
* @param phpbb_user $user
* @return string
*/
public function getLocalisedMessage(phpbb_user $user)
{
$parameters = $this->getParameters();
array_unshift($parameters, $this->getMessage());
return call_user_func_array(array($user, 'lang'), $parameters);
}
} }

View file

@ -49,7 +49,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac
{ {
if (isset($this->config[$config_name])) if (isset($this->config[$config_name]))
{ {
throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXISTS', $config_name); throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXIST', $config_name);
} }
$this->config->set($config_name, $config_value, !$is_dynamic); $this->config->set($config_name, $config_value, !$is_dynamic);

View file

@ -242,14 +242,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
if (!$module_id) if (!$module_id)
{ {
throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
} }
$parent = $data['parent_id'] = $module_id; $parent = $data['parent_id'] = $module_id;
} }
else if (!$this->exists($class, false, $parent)) else if (!$this->exists($class, false, $parent))
{ {
throw new phpbb_db_migration_exception('MODULE_PARENT_NOT_EXIST', $parent); throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
} }
if ($this->exists($class, $parent, $data['module_langname'])) if ($this->exists($class, $parent, $data['module_langname']))
@ -477,7 +477,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
$result = $acp_modules->delete_module($module_id); $result = $acp_modules->delete_module($module_id);
if (!empty($result)) if (!empty($result))
{ {
throw new phpbb_db_migration_exception('CANNOT_REMOVE_MODULE', $module_id); throw new phpbb_db_migration_exception('MODULE_NOT_REMOVABLE', $module_id, $result);
} }
} }

View file

@ -107,7 +107,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte
{ {
if ($this->exists($auth_option, $global)) if ($this->exists($auth_option, $global))
{ {
throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXISTS', $auth_option); throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXIST', $auth_option);
} }
// We've added permissions, so set to true to notify the user. // We've added permissions, so set to true to notify the user.
@ -252,7 +252,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte
if ($role_id) if ($role_id)
{ {
throw new phpbb_db_migration_exception('ROLE_ALREADY_EXISTS', $old_role_name); return;
} }
$sql = 'SELECT MAX(role_order) AS max_role_order $sql = 'SELECT MAX(role_order) AS max_role_order
@ -290,7 +290,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte
if (!$role_id) if (!$role_id)
{ {
throw new phpbb_db_migration_exception('ROLE_NOT_EXISTS', $old_role_name); throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $old_role_name);
} }
$sql = 'UPDATE ' . ACL_ROLES_TABLE . " $sql = 'UPDATE ' . ACL_ROLES_TABLE . "

View file

@ -228,9 +228,10 @@ class phpbb_db_migrator
{ {
foreach ($this->migrations as $name) foreach ($this->migrations as $name)
{ {
if ($this->unfulfillable($name)) $unfulfillable = $this->unfulfillable($name);
if ($unfulfillable !== false)
{ {
throw new phpbb_db_migration_exception('MIGRATION NOT FULFILLABLE', $name); throw new phpbb_db_migration_exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable);
} }
} }
} }
@ -674,7 +675,7 @@ class phpbb_db_migrator
* Checks if a migration's dependencies can even theoretically be satisfied. * Checks if a migration's dependencies can even theoretically be satisfied.
* *
* @param string $name The class name of the migration * @param string $name The class name of the migration
* @return bool Whether the migration cannot be fulfilled * @return bool|string False if fulfillable, string of missing migration name if unfulfillable
*/ */
public function unfulfillable($name) public function unfulfillable($name)
{ {
@ -685,7 +686,7 @@ class phpbb_db_migrator
if (!class_exists($name)) if (!class_exists($name))
{ {
return true; return $name;
} }
$migration = $this->get_migration($name); $migration = $this->get_migration($name);
@ -693,9 +694,10 @@ class phpbb_db_migrator
foreach ($depends as $depend) foreach ($depends as $depend)
{ {
if ($this->unfulfillable($depend)) $unfulfillable = $this->unfulfillable($depend);
if ($unfulfillable !== false)
{ {
return true; return $unfulfillable;
} }
} }
@ -715,7 +717,7 @@ class phpbb_db_migrator
{ {
// skip unfulfillable migrations, but fulfillables mean we // skip unfulfillable migrations, but fulfillables mean we
// are not finished yet // are not finished yet
if ($this->unfulfillable($name)) if ($this->unfulfillable($name) !== false)
{ {
continue; continue;
} }

View file

@ -15,6 +15,8 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* A base class for extensions without custom enable/disable/purge code. * A base class for extensions without custom enable/disable/purge code.
* *
@ -22,6 +24,19 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_extension_base implements phpbb_extension_interface class phpbb_extension_base implements phpbb_extension_interface
{ {
/** @var ContainerInterface */
protected $container;
/**
* Constructor
*
* @param ContainerInterface $container Container object
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/** /**
* Single enable step that does nothing * Single enable step that does nothing
* *

View file

@ -15,6 +15,8 @@ if (!defined('IN_PHPBB'))
exit; exit;
} }
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* The extension manager provides means to activate/deactivate extensions. * The extension manager provides means to activate/deactivate extensions.
* *
@ -22,8 +24,12 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_extension_manager class phpbb_extension_manager
{ {
/** @var ContainerInterface */
protected $container;
protected $db; protected $db;
protected $config; protected $config;
protected $migrator;
protected $cache; protected $cache;
protected $php_ext; protected $php_ext;
protected $extensions; protected $extensions;
@ -34,6 +40,7 @@ class phpbb_extension_manager
/** /**
* Creates a manager and loads information from database * Creates a manager and loads information from database
* *
* @param ContainerInterface $container A container
* @param phpbb_db_driver $db A database connection * @param phpbb_db_driver $db A database connection
* @param phpbb_config $config phpbb_config * @param phpbb_config $config phpbb_config
* @param string $extension_table The name of the table holding extensions * @param string $extension_table The name of the table holding extensions
@ -42,11 +49,13 @@ class phpbb_extension_manager
* @param phpbb_cache_driver_interface $cache A cache instance or null * @param phpbb_cache_driver_interface $cache A cache instance or null
* @param string $cache_name The name of the cache variable, defaults to _ext * @param string $cache_name The name of the cache variable, defaults to _ext
*/ */
public function __construct(phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_db_migrator $migrator, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
{ {
$this->container = $container;
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->db = $db; $this->db = $db;
$this->config = $config; $this->config = $config;
$this->migrator = $migrator;
$this->cache = $cache; $this->cache = $cache;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->extension_table = $extension_table; $this->extension_table = $extension_table;
@ -126,11 +135,11 @@ class phpbb_extension_manager
if (class_exists($extension_class_name)) if (class_exists($extension_class_name))
{ {
return new $extension_class_name; return new $extension_class_name($this->container);
} }
else else
{ {
return new phpbb_extension_base; return new phpbb_extension_base($this->container);
} }
} }
@ -166,6 +175,12 @@ class phpbb_extension_manager
$old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false; $old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false;
// Returns false if not completed
if (!$this->handle_migrations($name, 'enable'))
{
return true;
}
$extension = $this->get_extension($name); $extension = $this->get_extension($name);
$state = $extension->enable_step($old_state); $state = $extension->enable_step($old_state);
@ -317,6 +332,12 @@ class phpbb_extension_manager
$old_state = unserialize($this->extensions[$name]['ext_state']); $old_state = unserialize($this->extensions[$name]['ext_state']);
// Returns false if not completed
if (!$this->handle_migrations($name, 'purge'))
{
return true;
}
$extension = $this->get_extension($name); $extension = $this->get_extension($name);
$state = $extension->purge_step($old_state); $state = $extension->purge_step($old_state);
@ -490,4 +511,58 @@ class phpbb_extension_manager
{ {
return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
} }
/**
* Handle installing/reverting migrations
*
* @param string $extension_name Name of the extension
* @param string $mode enable or purge
* @return bool True if completed, False if not completed
*/
protected function handle_migrations($extension_name, $mode)
{
$migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/';
if (!file_exists($migrations_path) || !is_dir($migrations_path))
{
return true;
}
$migrations = $this->migrator->load_migrations($migrations_path);
// What is a safe limit of execution time? Half the max execution time should be safe.
$safe_time_limit = (ini_get('max_execution_time') / 2);
$start_time = time();
if ($mode == 'enable')
{
while (!$this->migrator->finished())
{
$this->migrator->update();
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $start_time) >= $safe_time_limit)
{
return false;
}
}
}
else if ($mode == 'purge')
{
foreach ($migrations as $migration)
{
while ($this->migrator->migration_state($migration) !== false)
{
$this->migrator->revert($migration);
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $start_time) >= $safe_time_limit)
{
return false;
}
}
}
}
return true;
}
} }

View file

@ -94,7 +94,7 @@ class phpbb_search_base
* *
* @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE * @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE
*/ */
function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir) function obtain_ids($search_key, &$result_count, &$id_ary, &$start, $per_page, $sort_dir)
{ {
global $cache; global $cache;
@ -109,6 +109,19 @@ class phpbb_search_base
$reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false; $reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false;
$complete = true; $complete = true;
// Change start parameter in case out of bounds
if ($result_count)
{
if ($start < 0)
{
$start = 0;
}
else if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
}
}
// change the start to the actual end of the current request if the sort direction differs // change the start to the actual end of the current request if the sort direction differs
// from the dirction in the cache and reverse the ids later // from the dirction in the cache and reverse the ids later
if ($reverse_ids) if ($reverse_ids)

View file

@ -353,7 +353,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results * @return boolean|int total number of results
*/ */
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{ {
// No keywords? No posts // No keywords? No posts
if (!$this->search_query) if (!$this->search_query)
@ -375,6 +375,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
implode(',', $author_ary) implode(',', $author_ary)
))); )));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache // try reading the results from cache
$result_count = 0; $result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -488,16 +493,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$id_ary = array_unique($id_ary); $id_ary = array_unique($id_ary);
if (!sizeof($id_ary))
{
return false;
}
// if the total result count is not cached yet, retrieve it from the db // if the total result count is not cached yet, retrieve it from the db
if (!$result_count) if (!$result_count)
{ {
$sql = 'SELECT FOUND_ROWS() as result_count'; $sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql_found_rows);
$result_count = (int) $this->db->sql_fetchfield('result_count'); $result_count = (int) $this->db->sql_fetchfield('result_count');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@ -507,6 +507,21 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
} }
} }
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page); $id_ary = array_slice($id_ary, 0, (int) $per_page);
@ -533,7 +548,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results * @return boolean|int total number of results
*/ */
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{ {
// No author? No posts // No author? No posts
if (!sizeof($author_ary)) if (!sizeof($author_ary))
@ -557,6 +572,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$author_name, $author_name,
))); )));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache // try reading the results from cache
$result_count = 0; $result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -662,8 +682,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
// retrieve the total result count if needed // retrieve the total result count if needed
if (!$result_count) if (!$result_count)
{ {
$sql = 'SELECT FOUND_ROWS() as result_count'; $sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql_found_rows);
$result_count = (int) $this->db->sql_fetchfield('result_count'); $result_count = (int) $this->db->sql_fetchfield('result_count');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@ -673,6 +693,20 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
} }
} }
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
if (sizeof($id_ary)) if (sizeof($id_ary))
{ {
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);

View file

@ -516,7 +516,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results * @return boolean|int total number of results
*/ */
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{ {
// No keywords? No posts. // No keywords? No posts.
if (empty($this->search_query)) if (empty($this->search_query))
@ -855,10 +855,6 @@ class phpbb_search_fulltext_native extends phpbb_search_base
} }
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
if (!sizeof($id_ary))
{
return false;
}
// if we use mysql and the total result count is not cached yet, retrieve it from the db // if we use mysql and the total result count is not cached yet, retrieve it from the db
if (!$total_results && $is_mysql) if (!$total_results && $is_mysql)
@ -867,14 +863,14 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$sql_array_copy = $sql_array; $sql_array_copy = $sql_array;
$sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id '; $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id ';
$sql = $this->db->sql_build_query('SELECT', $sql_array_copy); $sql_calc = $this->db->sql_build_query('SELECT', $sql_array_copy);
unset($sql_array_copy); unset($sql_array_copy);
$this->db->sql_query($sql); $this->db->sql_query($sql_calc);
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
$sql = 'SELECT FOUND_ROWS() as total_results'; $sql_count = 'SELECT FOUND_ROWS() as total_results';
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql_count);
$total_results = (int) $this->db->sql_fetchfield('total_results'); $total_results = (int) $this->db->sql_fetchfield('total_results');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@ -884,6 +880,20 @@ class phpbb_search_fulltext_native extends phpbb_search_base
} }
} }
if ($start >= $total_results)
{
$start = floor(($total_results - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')];
}
$this->db->sql_freeresult($result);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir); $this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page); $id_ary = array_slice($id_ary, 0, (int) $per_page);
@ -910,7 +920,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results * @return boolean|int total number of results
*/ */
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{ {
// No author? No posts // No author? No posts
if (!sizeof($author_ary)) if (!sizeof($author_ary))
@ -1096,13 +1106,13 @@ class phpbb_search_fulltext_native extends phpbb_search_base
if (!$total_results && $is_mysql) if (!$total_results && $is_mysql)
{ {
// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
$sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); $sql_calc = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql);
$this->db->sql_query($sql); $this->db->sql_query($sql_calc);
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
$sql = 'SELECT FOUND_ROWS() as total_results'; $sql_count = 'SELECT FOUND_ROWS() as total_results';
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql_count);
$total_results = (int) $this->db->sql_fetchfield('total_results'); $total_results = (int) $this->db->sql_fetchfield('total_results');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
@ -1112,6 +1122,19 @@ class phpbb_search_fulltext_native extends phpbb_search_base
} }
} }
if ($start >= $total_results)
{
$start = floor(($total_results - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
}
if (sizeof($id_ary)) if (sizeof($id_ary))
{ {
$this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir); $this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir);

View file

@ -343,7 +343,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results * @return boolean|int total number of results
*/ */
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{ {
// No keywords? No posts // No keywords? No posts
if (!$this->search_query) if (!$this->search_query)
@ -371,6 +371,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
implode(',', $author_ary) implode(',', $author_ary)
))); )));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache // try reading the results from cache
$result_count = 0; $result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -495,11 +500,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$id_ary = array_unique($id_ary); $id_ary = array_unique($id_ary);
if (!sizeof($id_ary))
{
return false;
}
// if the total result count is not cached yet, retrieve it from the db // if the total result count is not cached yet, retrieve it from the db
if (!$result_count) if (!$result_count)
{ {
@ -518,6 +518,21 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$this->db->sql_transaction('commit'); $this->db->sql_transaction('commit');
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir); $this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page); $id_ary = array_slice($id_ary, 0, (int) $per_page);
@ -544,7 +559,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results * @return boolean|int total number of results
*/ */
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{ {
// No author? No posts // No author? No posts
if (!sizeof($author_ary)) if (!sizeof($author_ary))
@ -568,6 +583,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$author_name, $author_name,
))); )));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache // try reading the results from cache
$result_count = 0; $result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE) if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -710,6 +730,20 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$this->db->sql_transaction('commit'); $this->db->sql_transaction('commit');
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
if (sizeof($id_ary)) if (sizeof($id_ary))
{ {
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir); $this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);

View file

@ -454,7 +454,7 @@ class phpbb_search_fulltext_sphinx
* @param int $per_page number of ids each page is supposed to contain * @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results * @return boolean|int total number of results
*/ */
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{ {
// No keywords? No posts. // No keywords? No posts.
if (!strlen($this->search_query) && !sizeof($author_ary)) if (!strlen($this->search_query) && !sizeof($author_ary))
@ -609,6 +609,25 @@ class phpbb_search_fulltext_sphinx
} }
} }
$result_count = $result['total_found'];
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES);
$result = $this->sphinx->Query($search_query_prefix . str_replace('&quot;', '"', $this->search_query), $this->indexes);
// Could be connection to localhost:9312 failed (errno=111,
// msg=Connection refused) during rotate, retry if so
$retries = SPHINX_CONNECT_RETRIES;
while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--)
{
usleep(SPHINX_CONNECT_WAIT_TIME);
$result = $this->sphinx->Query($search_query_prefix . str_replace('&quot;', '"', $this->search_query), $this->indexes);
}
}
$id_ary = array(); $id_ary = array();
if (isset($result['matches'])) if (isset($result['matches']))
{ {
@ -629,8 +648,6 @@ class phpbb_search_fulltext_sphinx
return false; return false;
} }
$result_count = $result['total_found'];
$id_ary = array_slice($id_ary, 0, (int) $per_page); $id_ary = array_slice($id_ary, 0, (int) $per_page);
return $result_count; return $result_count;
@ -878,8 +895,8 @@ class phpbb_search_fulltext_sphinx
<dd><input id="fulltext_sphinx_indexer_mem_limit" type="text" size="4" maxlength="10" name="config[fulltext_sphinx_indexer_mem_limit]" value="' . $this->config['fulltext_sphinx_indexer_mem_limit'] . '" /> ' . $this->user->lang['MIB'] . '</dd> <dd><input id="fulltext_sphinx_indexer_mem_limit" type="text" size="4" maxlength="10" name="config[fulltext_sphinx_indexer_mem_limit]" value="' . $this->config['fulltext_sphinx_indexer_mem_limit'] . '" /> ' . $this->user->lang['MIB'] . '</dd>
</dl> </dl>
<dl> <dl>
<dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</dt> <dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</span></dt>
<dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6">' . $this->config_file_data . '</textarea>' : $this->config_file_data) . '</dd> <dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6" id="sphinx_config_data">' . htmlspecialchars($this->config_file_data) . '</textarea>' : $this->config_file_data) . '</dd>
<dl> <dl>
'; ';

View file

@ -346,7 +346,7 @@ class phpbb_session
$session_id = $request->variable('sid', ''); $session_id = $request->variable('sid', '');
if (defined('NEED_SID') && (empty($session_id) || $this->session_id !== $session_id)) if (defined('NEED_SID') && (empty($session_id) || $this->session_id !== $session_id))
{ {
send_status_line(401, 'Not authorized'); send_status_line(401, 'Unauthorized');
redirect(append_sid("{$phpbb_root_path}index.$phpEx")); redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
} }

View file

@ -133,9 +133,7 @@ set_config(null, null, null, $config);
set_config_count(null, null, null, $config); set_config_count(null, null, null, $config);
$orig_version = $config['version']; $orig_version = $config['version'];
include($phpbb_root_path . 'language/' . $config['default_lang'] . '/common.' . $phpEx); $user->add_lang(array('common', 'acp/common', 'install', 'migrator'));
include($phpbb_root_path . 'language/' . $config['default_lang'] . '/acp/common.' . $phpEx);
include($phpbb_root_path . 'language/' . $config['default_lang'] . '/install.' . $phpEx);
// Add own hook handler, if present. :o // Add own hook handler, if present. :o
if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
@ -157,11 +155,11 @@ else
header('Content-type: text/html; charset=UTF-8'); header('Content-type: text/html; charset=UTF-8');
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html dir="<?php echo $lang['DIRECTION']; ?>" lang="<?php echo $lang['USER_LANG']; ?>"> <html dir="<?php echo $user->lang['DIRECTION']; ?>" lang="<?php echo $user->lang['USER_LANG']; ?>">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></title> <title><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></title>
<link href="<?php echo htmlspecialchars($phpbb_admin_path); ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" /> <link href="<?php echo htmlspecialchars($phpbb_admin_path); ?>style/admin.css" rel="stylesheet" type="text/css" media="screen" />
@ -178,12 +176,12 @@ header('Content-type: text/html; charset=UTF-8');
<div id="content"> <div id="content">
<div id="main" class="install-body"> <div id="main" class="install-body">
<h1><?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?></h1> <h1><?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?></h1>
<br /> <br />
<p><?php echo $lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br /> <p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br />
<?php echo $lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br /> <?php echo $user->lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br />
<?php <?php
@ -225,7 +223,7 @@ while (!$migrator->finished())
} }
catch (phpbb_db_migration_exception $e) catch (phpbb_db_migration_exception $e)
{ {
echo $e; echo $e->getLocalisedMessage($user);
phpbb_end_update($cache); phpbb_end_update($cache);
} }
@ -236,8 +234,8 @@ while (!$migrator->finished())
if ((time() - $update_start_time) >= $safe_time_limit) if ((time() - $update_start_time) >= $safe_time_limit)
{ {
//echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&amp;', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />'; //echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&amp;', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />';
echo $lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />'; echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />';
echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">' . $lang['DATABASE_UPDATE_CONTINUE'] . '</a>'; echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>';
phpbb_end_update($cache); phpbb_end_update($cache);
} }
@ -248,6 +246,6 @@ if ($orig_version != $config['version'])
add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']);
} }
echo $lang['DATABASE_UPDATE_COMPLETE']; echo $user->lang['DATABASE_UPDATE_COMPLETE'];
phpbb_end_update($cache); phpbb_end_update($cache);

View file

@ -1457,12 +1457,12 @@ class install_install extends module
*/ */
function add_modules($mode, $sub) function add_modules($mode, $sub)
{ {
global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config; global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config, $phpbb_container;
// modules require an extension manager // modules require an extension manager
if (empty($phpbb_extension_manager)) if (empty($phpbb_extension_manager))
{ {
$phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx"); $phpbb_extension_manager = $phpbb_container->get('ext.manager');
} }
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);

View file

@ -611,6 +611,7 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id,
# NEW MEMBERS on the queue # NEW MEMBERS on the queue
INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0);
# -- Demo Topic # -- Demo Topic
INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, '');

View file

@ -0,0 +1,56 @@
<?php
/**
*
* migrator [English]
*
* @package language
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'CONFIG_ALREADY_EXIST' => 'The config setting "%s" unexpectedly already exists.',
'CONFIG_NOT_EXIST' => 'The config setting "%s" unexpectedly does not exist.',
'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.',
'MIGRATION_EXCEPTION_ERROR' => 'Something went wrong during the request and an exception was thrown. The changes made before the error occurred were reversed to the best of our abilities, but you should check the board for errors.',
'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".',
'MODULE_ALREADY_EXIST' => 'The module "%s" unexpectedly already exists.',
'MODULE_ERROR' => 'An error occured while creating a module: %s',
'MODULE_INFO_FILE_NOT_EXIST' => 'A required module info file is missing: %2$s',
'MODULE_NOT_EXIST' => 'A required module does not exist: %s',
'MODULE_NOT_REMOVABLE' => 'Module %1$s was unable to be removed: %2$s',
'PERMISSION_ALREADY_EXIST' => 'The permission setting "%s" unexpectedly already exists.',
'PERMISSION_NOT_EXIST' => 'The permission setting "%s" unexpectedly does not exist.',
'ROLE_NOT_EXIST' => 'The permission role "%s" unexpectedly does not exist.',
));

View file

@ -25,14 +25,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
{ {
parent::setUp(); parent::setUp();
$this->extension_manager = new phpbb_extension_manager( $this->extension_manager = $this->create_extension_manager();
$this->new_dbal(),
new phpbb_config(array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.php',
new phpbb_mock_cache
);
} }
public function test_available() public function test_available()
@ -89,15 +82,30 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
public function test_enabled_no_cache() public function test_enabled_no_cache()
{ {
$extension_manager = new phpbb_extension_manager( $extension_manager = $this->create_extension_manager(false);
$this->new_dbal(),
new phpbb_config(array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.php'
);
$this->assertEquals(array('foo'), array_keys($extension_manager->all_enabled())); $this->assertEquals(array('foo'), array_keys($extension_manager->all_enabled()));
} }
protected function create_extension_manager($with_cache = true)
{
$config = new phpbb_config(array());
$db = $this->new_dbal();
$db_tools = new phpbb_db_tools($db);
$phpbb_root_path = __DIR__ . './../../phpBB/';
$php_ext = 'php';
$table_prefix = 'phpbb_';
return new phpbb_extension_manager(
new phpbb_mock_container_builder(),
$db,
$config,
new phpbb_db_migrator($config, $db, $db_tools, 'phpbb_migrations', $phpbb_root_path, $php_ext, $table_prefix, array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.' . $php_ext,
($with_cache) ? new phpbb_mock_cache() : null
);
}
} }

View file

@ -34,9 +34,11 @@ class metadata_manager_test extends phpbb_database_test_case
'version' => '3.1.0', 'version' => '3.1.0',
)); ));
$this->db = $this->new_dbal(); $this->db = $this->new_dbal();
$this->db_tools = new phpbb_db_tools($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpbb_root_path = dirname(__FILE__) . '/';
$this->phpEx = '.php'; $this->phpEx = '.php';
$this->user = new phpbb_user(); $this->user = new phpbb_user();
$this->table_prefix = 'phpbb_';
$this->template = new phpbb_template( $this->template = new phpbb_template(
$this->phpbb_root_path, $this->phpbb_root_path,
@ -48,8 +50,10 @@ class metadata_manager_test extends phpbb_database_test_case
); );
$this->extension_manager = new phpbb_extension_manager( $this->extension_manager = new phpbb_extension_manager(
new phpbb_mock_container_builder(),
$this->db, $this->db,
$this->config, $this->config,
new phpbb_db_migrator($this->config, $this->db, $this->db_tools, 'phpbb_migrations', $this->phpbb_root_path, $this->php_ext, $this->table_prefix, array()),
'phpbb_ext', 'phpbb_ext',
$this->phpbb_root_path, $this->phpbb_root_path,
$this->phpEx, $this->phpEx,

View file

@ -134,19 +134,20 @@ class phpbb_functional_test_case extends phpbb_test_case
{ {
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
if (!$this->extension_manager) $config = new phpbb_config(array());
{ $db = $this->get_db();
$this->extension_manager = new phpbb_extension_manager( $db_tools = new phpbb_db_tools($db);
$this->get_db(),
new phpbb_config(array()),
self::$config['table_prefix'] . 'ext',
$phpbb_root_path,
".$phpEx",
$this->get_cache_driver()
);
}
return $this->extension_manager; return new phpbb_extension_manager(
new phpbb_mock_container_builder(),
$db,
$config,
new phpbb_db_migrator($config, $db, $db_tools, self::$config['table_prefix'] . 'migrations', $phpbb_root_path, $php_ext, self::$config['table_prefix'], array()),
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
'.' . $php_ext,
$this->get_cache_driver()
);
} }
static protected function install_board() static protected function install_board()