Allow user colours to be NULL instead of 0x40000000.
This commit is contained in:
parent
2ef4d6d66d
commit
63769ce72d
3 changed files with 17 additions and 6 deletions
14
database/2025_01_19_205947_fix_user_colour_field.php
Normal file
14
database/2025_01_19_205947_fix_user_colour_field.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
use Index\Db\DbConnection;
|
||||||
|
use Index\Db\Migration\DbMigration;
|
||||||
|
|
||||||
|
final class FixUserColourField_20250119_205947 implements DbMigration {
|
||||||
|
public function migrate(DbConnection $conn): void {
|
||||||
|
$conn->execute(<<<SQL
|
||||||
|
ALTER TABLE ser_users
|
||||||
|
CHANGE COLUMN user_colour user_colour INT(10) UNSIGNED NULL DEFAULT NULL AFTER user_name;
|
||||||
|
SQL);
|
||||||
|
|
||||||
|
$conn->execute('UPDATE ser_users SET user_colour = NULL WHERE user_colour & 0x40000000');
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,12 +19,10 @@ class UserInfo {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public static function fromResult(DbResult $result): UserInfo {
|
public static function fromResult(DbResult $result): UserInfo {
|
||||||
$colour = $result->getIntegerOrNull(2);
|
|
||||||
|
|
||||||
return new UserInfo(
|
return new UserInfo(
|
||||||
id: $result->getString(0),
|
id: $result->getString(0),
|
||||||
name: $result->getString(1),
|
name: $result->getString(1),
|
||||||
colourRaw: $colour === null || $colour & 0x40000000 ? null : $colour,
|
colourRaw: $result->getIntegerOrNull(2),
|
||||||
rank: $result->getInteger(3),
|
rank: $result->getInteger(3),
|
||||||
perms: $result->getInteger(4),
|
perms: $result->getInteger(4),
|
||||||
passKey: $result->getStringOrNull(5),
|
passKey: $result->getStringOrNull(5),
|
||||||
|
|
|
@ -20,14 +20,13 @@ class Users {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncApiUser(V1User $authInfo): void {
|
public function syncApiUser(V1User $authInfo): void {
|
||||||
$userColourUnfixed = $authInfo->getColourRaw() ?? 0x40000000;
|
|
||||||
$stmt = $this->cache->get('INSERT INTO ser_users (user_id, user_name, user_colour, user_rank, user_permissions) VALUES (?, ?, ?, ?, 0) ON DUPLICATE KEY UPDATE user_name = ?, user_colour = ?, user_rank = ?');
|
$stmt = $this->cache->get('INSERT INTO ser_users (user_id, user_name, user_colour, user_rank, user_permissions) VALUES (?, ?, ?, ?, 0) ON DUPLICATE KEY UPDATE user_name = ?, user_colour = ?, user_rank = ?');
|
||||||
$stmt->nextParameter($authInfo->getId());
|
$stmt->nextParameter($authInfo->getId());
|
||||||
$stmt->nextParameter($authInfo->getName());
|
$stmt->nextParameter($authInfo->getName());
|
||||||
$stmt->nextParameter($userColourUnfixed);
|
$stmt->nextParameter($authInfo->getColourRaw());
|
||||||
$stmt->nextParameter($authInfo->getRank());
|
$stmt->nextParameter($authInfo->getRank());
|
||||||
$stmt->nextParameter($authInfo->getName());
|
$stmt->nextParameter($authInfo->getName());
|
||||||
$stmt->nextParameter($userColourUnfixed);
|
$stmt->nextParameter($authInfo->getColourRaw());
|
||||||
$stmt->nextParameter($authInfo->getRank());
|
$stmt->nextParameter($authInfo->getRank());
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue