Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #855

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gatherling/Data/sql/migrations/80.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- We must explicitly set this (which we did not at creation time) because server default may differ.
-- Our other tables have this explicitly set in schema.sql.
ALTER TABLE sessions CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
5 changes: 4 additions & 1 deletion gatherling/Models/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,10 @@ public function updateLegalList(array $addCards, array $delCards): array
*/
private function getCurrentLegalityOfCards(array $cards): array
{
$sql = "CREATE TEMPORARY TABLE input_cards (original_name VARCHAR(160))";
$sql = '
CREATE TEMPORARY TABLE input_cards (
original_name VARCHAR(160)
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci';
db()->execute($sql);

$placeholders = $params = [];
Expand Down
3 changes: 3 additions & 0 deletions gatherling/Models/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ public static function sanitizeUsername(string $playerName): string

public static function createByName(string $playername): self
{
if (strlen($playername) > 40) {
throw new ValidationException('Username too long (must be less than 40 characters)');
}
$sql = 'INSERT INTO players (name) VALUES (:player_name)';
$params = ['player_name' => $playername];
db()->execute($sql, $params);
Expand Down
2 changes: 1 addition & 1 deletion gatherling/Models/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Series
public array $bannedplayers;
public ?string $mtgo_room;

public ?string $this_season_format;
public ?string $this_season_format = null;
public ?string $this_season_master_link = null;
public int $this_season_season;

Expand Down
20 changes: 10 additions & 10 deletions gatherling/Views/Components/FullMetagame.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ public function __construct(Event $event)
$players[] = $info;
}
$sql = '
CREATE TEMPORARY TABLE meta
(
player VARCHAR(40),
deckname VARCHAR(120),
archetype VARCHAR(20),
colors VARCHAR(10),
medal VARCHAR(10),
id BIGINT UNSIGNED,
srtordr TINYINT UNSIGNED DEFAULT 0
)';
CREATE TEMPORARY TABLE meta (
player VARCHAR(40),
deckname VARCHAR(120),
archetype VARCHAR(20),
colors VARCHAR(10),
medal VARCHAR(10),
id BIGINT UNSIGNED,
srtordr TINYINT UNSIGNED DEFAULT 0
)
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci';
db()->execute($sql);
$sql = '
INSERT INTO meta
Expand Down