mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-04 06:39:14 +02:00
[ticket/13033] Fix "Duplicate entry 'notification.type.*' for key 'type'"
Caused by the solution of PHPBB3-12990 PHPBB3-13033
This commit is contained in:
parent
40cd7570e6
commit
3d9b257597
@ -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…
x
Reference in New Issue
Block a user