boolinate locked

This commit is contained in:
Shish 2020-10-27 01:05:12 +00:00
parent ee7a4f178c
commit 10f563ee37
3 changed files with 8 additions and 12 deletions

View file

@ -659,16 +659,12 @@ class Image
return $this->locked;
}
public function set_locked(bool $tf): void
public function set_locked(bool $locked): void
{
global $database;
$ln = $tf ? "Y" : "N";
$sln = $database->scoreql_to_sql('SCORE_BOOL_'.$ln);
$sln = str_replace("'", "", $sln);
$sln = str_replace('"', "", $sln);
if (bool_escape($sln) !== $this->locked) {
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn"=>$sln, "id"=>$this->id]);
log_info("core_image", "Setting Image #{$this->id} lock to: $ln");
if ($locked !== $this->locked) {
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn"=>$locked, "id"=>$this->id]);
log_info("core_image", "Setting Image #{$this->id} lock to: $locked");
}
}

View file

@ -255,7 +255,7 @@ function create_tables(Database $db)
width INTEGER NOT NULL,
height INTEGER NOT NULL,
posted TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
locked BOOLEAN NOT NULL DEFAULT FALSE,
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
");
$db->execute("CREATE INDEX images_owner_id_idx ON images(owner_id)", []);

View file

@ -32,9 +32,9 @@ class Upgrade extends Extension
// now done again as v9 with PDO
if ($this->get_version("db_version") < 8) {
$database->execute($database->scoreql_to_sql(
"ALTER TABLE images ADD COLUMN locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N"
));
$database->execute(
"ALTER TABLE images ADD COLUMN locked BOOLEAN NOT NULL DEFAULT FALSE"
);
$this->set_version("db_version", 8);
}