mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-16 15:08:54 +00:00
[ticket/17507] General SQL error on installing remove_jabber.php migration
The issue affects probably any DBMS excluding MySQL/MariaDB. PHPBB-17507
This commit is contained in:
parent
4f89e2b97d
commit
e4cd3ac744
1 changed files with 31 additions and 6 deletions
|
@ -34,6 +34,11 @@ class remove_jabber extends migration
|
|||
$this->table_prefix . 'users' => [
|
||||
'user_jabber',
|
||||
],
|
||||
],
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'user_notifications' => [
|
||||
'id' => ['ULINT', null, 'auto_increment'],
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
@ -45,7 +50,12 @@ class remove_jabber extends migration
|
|||
$this->table_prefix . 'users' => [
|
||||
'user_jabber' => ['VCHAR_UNI', ''],
|
||||
],
|
||||
]
|
||||
],
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'user_notifications' => [
|
||||
'id',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -101,11 +111,26 @@ class remove_jabber extends migration
|
|||
];
|
||||
}
|
||||
|
||||
public function move_jabber_to_email_notifications()
|
||||
public function move_jabber_to_email_notifications(int|null $start)
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->tables['user_notifications'] . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . "
|
||||
WHERE method = 'notification.method.jabber'";
|
||||
$this->db->sql_query($sql);
|
||||
$limit = 1000;
|
||||
|
||||
$sql = 'SELECT id FROM ' . $this->tables['user_notifications'] . "
|
||||
WHERE method = 'notification.method.jabber'
|
||||
ORDER BY id ASC";
|
||||
$result = $this->db->sql_query_limit($sql, $limit, $start ?: 0);
|
||||
$rowset = $this->db->sql_fetchrowset($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
$ids_array = array_column($rowset, 'id');
|
||||
|
||||
if (count($ids_array))
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->tables['user_notifications'] . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', ['method' => 'notification.method.email']) . '
|
||||
WHERE ' . $this->db->sql_in_set('id', $ids_array);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
return count($ids_array) < $limit ? true : $start + $limit;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue