mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
Merge remote-tracking branch 'EXreaction/ticket/11351' into develop
# By Nathaniel Guse (4) and Nathan Guse (1) # Via Nathan Guse * EXreaction/ticket/11351: [feature/migrations] getLocalisedMessage function for migration exception [feature/migrations] Fix unfulfillable function [feature/migrations] getParameters function for migration exception [feature/migrations] Add explanatory language string for migration errors [feature/migrations] Add language strings for migrations errors
This commit is contained in:
commit
0987efa189
6 changed files with 96 additions and 14 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 . "
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
56
phpBB/language/en/migrator.php
Normal file
56
phpBB/language/en/migrator.php
Normal 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.',
|
||||
));
|
Loading…
Add table
Reference in a new issue