mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-18 17:28:56 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/13033] Fix "Duplicate entry 'notification.type.*' for key 'type'"
This commit is contained in:
commit
b354afdeb4
1 changed files with 70 additions and 8 deletions
|
@ -92,10 +92,41 @@ class notifications_use_full_name extends \phpbb\db\migration\migration
|
|||
|
||||
foreach ($this->notification_types as $notification_type)
|
||||
{
|
||||
$sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . "
|
||||
SET notification_type_name = 'notification.type.{$notification_type}'
|
||||
WHERE notification_type_name = '{$notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
$sql = 'SELECT notification_type_id
|
||||
FROM ' . NOTIFICATION_TYPES_TABLE . "
|
||||
WHERE notification_type_name = 'notification.type.{$notification_type}'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$new_type_id = (int) $this->db->sql_fetchfield('notification_type_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($new_type_id)
|
||||
{
|
||||
// New type name already exists,
|
||||
// so we delete the old type and update the type id of existing entries.
|
||||
$sql = 'SELECT notification_type_id
|
||||
FROM ' . NOTIFICATION_TYPES_TABLE . "
|
||||
WHERE notification_type_name = '{$notification_type}'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$old_type_id = (int) $this->db->sql_fetchfield('notification_type_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
||||
SET notification_type_id = ' . (int) $new_type_id . '
|
||||
WHERE notification_type_id = ' . (int) $old_type_id;
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$sql = 'DELETE FROM ' . NOTIFICATION_TYPES_TABLE . "
|
||||
WHERE notification_type_name = '{$notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise we just update the name
|
||||
$sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . "
|
||||
SET notification_type_name = 'notification.type.{$notification_type}'
|
||||
WHERE notification_type_name = '{$notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
|
||||
SET item_type = 'notification.type.{$notification_type}'
|
||||
|
@ -108,10 +139,41 @@ class notifications_use_full_name extends \phpbb\db\migration\migration
|
|||
{
|
||||
foreach ($this->notification_types as $notification_type)
|
||||
{
|
||||
$sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . "
|
||||
SET notification_type_name = '{$notification_type}'
|
||||
WHERE notification_type_name = 'notification.type.{$notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
$sql = 'SELECT notification_type_id
|
||||
FROM ' . NOTIFICATION_TYPES_TABLE . "
|
||||
WHERE notification_type_name = '{$notification_type}'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$new_type_id = (int) $this->db->sql_fetchfield('notification_type_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($new_type_id)
|
||||
{
|
||||
// New type name already exists,
|
||||
// so we delete the old type and update the type id of existing entries.
|
||||
$sql = 'SELECT notification_type_id
|
||||
FROM ' . NOTIFICATION_TYPES_TABLE . "
|
||||
WHERE notification_type_name = 'notification.type.{$notification_type}'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$old_type_id = (int) $this->db->sql_fetchfield('notification_type_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
||||
SET notification_type_id = ' . (int) $new_type_id . '
|
||||
WHERE notification_type_id = ' . (int) $old_type_id;
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$sql = 'DELETE FROM ' . NOTIFICATION_TYPES_TABLE . "
|
||||
WHERE notification_type_name = 'notification.type.{$notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise we just update the name
|
||||
$sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . "
|
||||
SET notification_type_name = '{$notification_type}'
|
||||
WHERE notification_type_name = 'notification.type.{$notification_type}'";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
$sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
|
||||
SET item_type = '{$notification_type}'
|
||||
|
|
Loading…
Add table
Reference in a new issue