From ed735e17be201c30449ad9fd8ea65977313aca9b Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 27 Oct 2020 00:34:28 +0000 Subject: [PATCH] boolinate image --- core/imageboard/image.php | 2 +- ext/media/main.php | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/core/imageboard/image.php b/core/imageboard/image.php index 0ee6d379..764022a7 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -459,7 +459,7 @@ class Image "lossless" => $database->scoresql_value_prepare($this->lossless), "video" => $database->scoresql_value_prepare($this->video), "video_codec" => $this->video_codec, - "image" => $database->scoresql_value_prepare($this->image), + "image" => $this->image, "audio" => $database->scoresql_value_prepare($this->audio), "length" => $this->length ] diff --git a/ext/media/main.php b/ext/media/main.php index 107f08e6..695444b7 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -918,9 +918,7 @@ class Media extends Extension } if ($this->get_version(MediaConfig::VERSION) < 2) { - $database->execute($database->scoreql_to_sql( - "ALTER TABLE images ADD COLUMN image SCORE_BOOL NULL" - )); + $database->execute("ALTER TABLE images ADD COLUMN image BOOLEAN NULL"); switch ($database->get_driver_name()) { case DatabaseDriver::PGSQL: @@ -932,24 +930,24 @@ class Media extends Extension break; } - $database->set_timeout(300000); // These updates can take a little bit - - if ($database->transaction === true) { - $database->commit(); // Each of these commands could hit a lot of data, combining them into one big transaction would not be a good idea. - } - log_info("upgrade", "Setting predictable media values for known file types"); - $database->execute($database->scoreql_to_sql("UPDATE images SET image = SCORE_BOOL_N WHERE ext IN ('swf','mp3','ani','flv','mp4','m4v','ogv','webm')")); - $database->execute($database->scoreql_to_sql("UPDATE images SET image = SCORE_BOOL_Y WHERE ext IN ('jpg','jpeg','ico','cur','png')")); - $this->set_version(MediaConfig::VERSION, 2); - - $database->begin_transaction(); } if ($this->get_version(MediaConfig::VERSION) < 3) { $database->execute("ALTER TABLE images ADD COLUMN video_codec varchar(512) NULL"); $this->set_version(MediaConfig::VERSION, 3); } + + if ($this->get_version(MediaConfig::VERSION) < 4) { + $database->standardise_boolean("images", "image"); + $this->set_version(MediaConfig::VERSION, 4); + } + + if ($this->get_version(MediaConfig::VERSION) < 5) { + $database->execute("UPDATE images SET image = :f WHERE ext IN ('swf','mp3','ani','flv','mp4','m4v','ogv','webm')", ["f"=>false]); + $database->execute("UPDATE images SET image = :t WHERE ext IN ('jpg','jpeg','ico','cur','png')", ["t"=>true]); + $this->set_version(MediaConfig::VERSION, 5); + } } public static function hex_color_allocate($im, $hex)