databases??

This commit is contained in:
Shish 2024-01-15 22:56:06 +00:00
parent 5d120cd0c8
commit 641821f6f1
4 changed files with 13 additions and 9 deletions

View file

@ -30,9 +30,11 @@ class MimeSystem extends Extension
// adjustment needs to be made to the mime types.
if ($this->get_version(self::VERSION) < 1) {
// Each of these commands could hit a lot of data, combining
// them into one big transaction would not be a good idea.
$database->commit();
if ($database->is_transaction_open()) {
// Each of these commands could hit a lot of data, combining
// them into one big transaction would not be a good idea.
$database->commit();
}
$database->set_timeout(null); // These updates can take a little bit
$extensions = $database->get_col_iterable("SELECT DISTINCT ext FROM images");

View file

@ -193,9 +193,11 @@ class Upgrade extends Extension
if ($this->get_version("db_version") < 21) {
log_info("upgrade", "Setting predictable media values for known file types");
// Each of these commands could hit a lot of data, combining
// them into one big transaction would not be a good idea.
$database->commit();
if ($database->is_transaction_open()) {
// Each of these commands could hit a lot of data, combining
// them into one big transaction would not be a good idea.
$database->commit();
}
$database->execute("UPDATE images SET lossless = :t, video = :t WHERE ext IN ('swf')", ["t" => true]);
$database->execute("UPDATE images SET lossless = :f, video = :f, audio = :t WHERE ext IN ('mp3')", ["t" => true, "f" => false]);
$database->execute("UPDATE images SET lossless = :f, video = :f, audio = :f WHERE ext IN ('jpg','jpeg')", ["f" => false]);

View file

@ -45,9 +45,10 @@ class UploadTest extends ShimmiePHPUnitTestCase
];
$page = $this->post_page("upload", ["tags0" => "foo bar"]);
$this->assert_response(302);
$this->assertStringStartsWith("/test/post/list/id%3D4%2C3%2C2%2C1/1", $page->redirect);
$this->assertEquals(4, $database->get_one("SELECT COUNT(*) FROM images"));
// FIXME: image IDs get allocated even when transactions are rolled back,
// so these IDs are not necessarily correct
// $this->assertStringStartsWith("/test/post/list/id%3D4%2C3%2C2%2C1/1", $page->redirect);
}
public function testUpload(): void

View file

@ -42,4 +42,3 @@ $userPage->onUserCreation(new UserCreationEvent("demo", "demo", "demo", "demo@de
$userPage->onUserCreation(new UserCreationEvent("test", "test", "test", "test@test.com", false));
$database->commit();
$_tracer->end();