1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 01:06:48 +02:00

Merge branch 'develop' of git://github.com/phpbb/phpbb3 into feature/migrations-data

Conflicts:
	phpBB/install/database_update.php
This commit is contained in:
Nathaniel Guse
2013-02-23 15:05:47 -06:00
24 changed files with 429 additions and 138 deletions

View File

@@ -303,7 +303,7 @@ class phpbb_db_tools
* @param phpbb_db_driver $db Database connection
* @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->return_statements = $return_statements;

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);
}
/**
* 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]))
{
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);

View File

@@ -242,14 +242,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
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;
}
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']))
@@ -477,7 +477,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
$result = $acp_modules->delete_module($module_id);
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))
{
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.
@@ -252,7 +252,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte
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
@@ -290,7 +290,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte
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 . "

View File

@@ -228,9 +228,10 @@ class phpbb_db_migrator
{
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.
*
* @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)
{
@@ -685,7 +686,7 @@ class phpbb_db_migrator
if (!class_exists($name))
{
return true;
return $name;
}
$migration = $this->get_migration($name);
@@ -693,9 +694,10 @@ class phpbb_db_migrator
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
// are not finished yet
if ($this->unfulfillable($name))
if ($this->unfulfillable($name) !== false)
{
continue;
}