From cc06df171a2f86f3bd7e0496940291c2f484be3a Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 26 Oct 2020 22:37:25 +0000 Subject: [PATCH] Argh, that doesn't work for OTHER versions of sqlite... This reverts commit 55e3cb5d63f3611cf2deac714db57c41d1aded98. --- core/database.php | 2 +- core/imageboard/image.php | 10 +++++----- ext/blotter/main.php | 2 +- ext/forum/main.php | 2 +- ext/pm/main.php | 2 +- ext/pools/main.php | 2 +- ext/private_image/main.php | 16 ++++++++-------- ext/relationships/main.php | 2 +- ext/tips/main.php | 2 +- ext/trash/main.php | 4 ++-- ext/wiki/main.php | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/core/database.php b/core/database.php index ace1c655..f4431aaa 100644 --- a/core/database.php +++ b/core/database.php @@ -374,7 +374,7 @@ class Database $this->execute("UPDATE $table SET $column = ($column IN ('Y', 1))"); } if ($d == DatabaseDriver::PGSQL) { - $this->execute("ALTER TABLE $table ADD COLUMN ${column}_b BOOLEAN DEFAULT (1=0) NOT NULL"); + $this->execute("ALTER TABLE $table ADD COLUMN ${column}_b BOOLEAN DEFAULT FALSE NOT NULL"); $this->execute("UPDATE $table SET ${column}_b = ($column = 'Y')"); $this->execute("ALTER TABLE $table DROP COLUMN $column"); $this->execute("ALTER TABLE $table RENAME COLUMN ${column}_b TO $column"); diff --git a/core/imageboard/image.php b/core/imageboard/image.php index 27738817..e5f2b156 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -456,11 +456,11 @@ class Image "id" => $this->id, "width" => $this->width ?? 0, "height" => $this->height ?? 0, - "lossless" => $this->lossless, - "video" => $this->video, - "video_codec" => $this->video_codec, - "image" => $this->image, - "audio" => $this->audio, + "lossless" => $database->scoresql_value_prepare($this->lossless), + "video" => $database->scoresql_value_prepare($this->video), + "video_codec" => $database->scoresql_value_prepare($this->video_codec), + "image" => $database->scoresql_value_prepare($this->image), + "audio" => $database->scoresql_value_prepare($this->audio), "length" => $this->length ] ); diff --git a/ext/blotter/main.php b/ext/blotter/main.php index f237ce8f..5a043a99 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -22,7 +22,7 @@ class Blotter extends Extension id SCORE_AIPK, entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, entry_text TEXT NOT NULL, - important BOOLEAN NOT NULL DEFAULT (1=0) + important BOOLEAN NOT NULL DEFAULT FALSE "); // Insert sample data: $database->execute( diff --git a/ext/forum/main.php b/ext/forum/main.php index 4400fd12..5539e6d8 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -21,7 +21,7 @@ class Forum extends Extension if ($config->get_int("forum_version") < 1) { $database->create_table("forum_threads", " id SCORE_AIPK, - sticky BOOLEAN NOT NULL DEFAULT (1=0), + sticky BOOLEAN NOT NULL DEFAULT FALSE, title VARCHAR(255) NOT NULL, user_id INTEGER NOT NULL, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/ext/pm/main.php b/ext/pm/main.php index fbda0bb7..fb72fea5 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -74,7 +74,7 @@ class PrivMsg extends Extension sent_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, subject VARCHAR(64) NOT NULL, message TEXT NOT NULL, - is_read BOOLEAN NOT NULL DEFAULT (1=0), + is_read BOOLEAN NOT NULL DEFAULT FALSE, FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE "); diff --git a/ext/pools/main.php b/ext/pools/main.php index ccdad21e..4c9e99e5 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -132,7 +132,7 @@ class Pools extends Extension $database->create_table("pools", " id SCORE_AIPK, user_id INTEGER NOT NULL, - public BOOLEAN NOT NULL DEFAULT (1=0), + public BOOLEAN NOT NULL DEFAULT FALSE, title VARCHAR(255) NOT NULL, description TEXT, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/ext/private_image/main.php b/ext/private_image/main.php index a3b92a3d..316d079e 100644 --- a/ext/private_image/main.php +++ b/ext/private_image/main.php @@ -133,13 +133,13 @@ class PrivateImage extends Extension if ($show_private) { $event->add_querylet( new Querylet( - "private = :false OR owner_id = :private_owner_id", - ["private_owner_id"=>$user->id, "false"=>false] + "private != :true OR owner_id = :private_owner_id", + ["private_owner_id"=>$user->id, "true"=>true] ) ); } else { $event->add_querylet( - new Querylet("private = :false", ["false"=>false]) + new Querylet("private != :true", ["true"=>true]) ); } } @@ -153,8 +153,8 @@ class PrivateImage extends Extension $query = ""; switch ($matches[1]) { case "no": - $query .= "private = :false"; - $params["false"] = false; + $query .= "private != :true"; + $params["true"] = true; break; case "yes": $query .= "private = :true"; @@ -168,8 +168,8 @@ class PrivateImage extends Extension } break; case "any": - $query .= "private = :false OR owner_id = :private_owner_id"; - $params["false"] = false; + $query .= "private != :true OR owner_id = :private_owner_id"; + $params["true"] = true; $params["private_owner_id"] = $user->id; break; } @@ -280,7 +280,7 @@ class PrivateImage extends Extension global $database; if ($this->get_version(PrivateImageConfig::VERSION) < 1) { - $database->execute("ALTER TABLE images ADD COLUMN private BOOLEAN NOT NULL DEFAULT (1=0)"); + $database->execute("ALTER TABLE images ADD COLUMN private BOOLEAN NOT NULL DEFAULT FALSE"); $database->execute("CREATE INDEX images_private_idx ON images(private)"); $this->set_version(PrivateImageConfig::VERSION, 2); } diff --git a/ext/relationships/main.php b/ext/relationships/main.php index da6ef7c8..9a89d5f3 100644 --- a/ext/relationships/main.php +++ b/ext/relationships/main.php @@ -33,7 +33,7 @@ class Relationships extends Extension if ($this->get_version("ext_relationships_version") < 1) { $database->execute("ALTER TABLE images ADD parent_id INT"); - $database->execute("ALTER TABLE images ADD has_children BOOLEAN DEFAULT (1=0) NOT NULL"); + $database->execute("ALTER TABLE images ADD has_children BOOLEAN DEFAULT FALSE NOT NULL"); $database->execute("CREATE INDEX images__parent_id ON images(parent_id)"); $database->execute("CREATE INDEX images__has_children ON images(has_children)"); $this->set_version("ext_relationships_version", 3); diff --git a/ext/tips/main.php b/ext/tips/main.php index 9e3e5b64..0b6ca226 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -36,7 +36,7 @@ class Tips extends Extension if ($this->get_version("ext_tips_version") < 1) { $database->create_table("tips", " id SCORE_AIPK, - enable BOOLEAN NOT NULL DEFAULT (1=0), + enable BOOLEAN NOT NULL DEFAULT FALSE, image TEXT NOT NULL, text TEXT NOT NULL, "); diff --git a/ext/trash/main.php b/ext/trash/main.php index a1493c9b..91dcf985 100644 --- a/ext/trash/main.php +++ b/ext/trash/main.php @@ -97,7 +97,7 @@ class Trash extends Extension $matches = []; if (is_null($event->term) && $this->no_trash_query($event->context)) { - $event->add_querylet(new Querylet("trash = :false", ["false"=>false])); + $event->add_querylet(new Querylet("trash != :true", ["true"=>true])); } if (is_null($event->term)) { @@ -182,7 +182,7 @@ class Trash extends Extension global $database; if ($this->get_version(TrashConfig::VERSION) < 1) { - $database->execute("ALTER TABLE images ADD COLUMN trash BOOLEAN NOT NULL DEFAULT (1=0)"); + $database->execute("ALTER TABLE images ADD COLUMN trash BOOLEAN NOT NULL DEFAULT FALSE"); $database->execute("CREATE INDEX images_trash_idx ON images(trash)"); $this->set_version(TrashConfig::VERSION, 2); } diff --git a/ext/wiki/main.php b/ext/wiki/main.php index f4e52613..c85eeeb5 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -133,7 +133,7 @@ class Wiki extends Extension date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, title VARCHAR(255) NOT NULL, revision INTEGER NOT NULL DEFAULT 1, - locked BOOLEAN NOT NULL DEFAULT (1=0), + locked BOOLEAN NOT NULL DEFAULT FALSE, body TEXT NOT NULL, UNIQUE (title, revision), FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT