[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:
rxu 2025-07-05 22:23:26 +07:00
parent 4f89e2b97d
commit e4cd3ac744
No known key found for this signature in database
GPG key ID: 955F0567380E586A

View file

@ -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;
}
}