diff --git a/lib/Database.php b/lib/Database.php index bb2ebba..4a5b27d 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -51,7 +51,7 @@ class Database { } public function schemaUpdate(): bool { - if($this->db->schemaVersion() < self::SCHEMA_VERSION) return $this->db->update(self::SCHEMA_VERSION); + if($this->db->schemaVersion() < self::SCHEMA_VERSION) return $this->db->schemaUpdate(self::SCHEMA_VERSION); return false; } @@ -163,11 +163,11 @@ class Database { $value =& $in; break; } - $this->db->prepare("REPLACE INTO newssync_settings(key,value,type) values(?,?,?)", "str", (($type=="null") ? "null" : "str"), "str")->run($key, $value, "text"); + $this->db->prepare("REPLACE INTO newssync_settings(key,value,type) values(?,?,?)", "str", "str", "str")->run($key, $value, $type); } public function settingRemove(string $key): bool { - $this->db->prepare("DELETE from newssync_settings where key = ?", "str")->run($key); + $this->db->prepare("DELETE from newssync_settings where key is ?", "str")->run($key); return true; } @@ -182,7 +182,7 @@ class Database { if($password===null) $password = (new PassGen)->length($this->data->conf->userTempPasswordLength)->get(); $hash = ""; if(strlen($password) > 0) $hash = password_hash($password, \PASSWORD_DEFAULT); - $this->db->prepare("INSERT INTO newssync_users(id,password) values(?,?)", "str", "str")->run($user,$hash); + $this->db->prepare("INSERT INTO newssync_users(id,password) values(?,?)", "str", "str")->runArray([$user,$hash]); return $password; } @@ -295,7 +295,7 @@ class Database { $url, $feed->title, // Grab the favicon for the Goodfeed; returns an empty string if it cannot find one. - (new PicoFeed\Reader\Favicon)->find($url), + (new \PicoFeed\Reader\Favicon)->find($url), $feed->siteUrl, $feed->date, $resource->getLastModified(), diff --git a/lib/Db/Driver.php b/lib/Db/Driver.php index ad4d5fb..aaf8440 100644 --- a/lib/Db/Driver.php +++ b/lib/Db/Driver.php @@ -19,7 +19,7 @@ interface Driver { function unlock(): bool; function isLocked(): bool; // attempt to perform an in-place upgrade of the database schema; this may be a no-op which always throws an exception - function update(int $to): bool; + function schemaUpdate(int $to): bool; // execute one or more unsanitized SQL queries and return an indication of success function exec(string $query): bool; // perform a single unsanitized query and return a result set diff --git a/lib/Db/StatementSQLite3.php b/lib/Db/StatementSQLite3.php index 23dfb0b..608a988 100644 --- a/lib/Db/StatementSQLite3.php +++ b/lib/Db/StatementSQLite3.php @@ -52,11 +52,11 @@ class StatementSQLite3 extends AbstractStatement { $type = \SQLITE3_TEXT; } // cast value if necessary - $value = $this->cast($values[$a], $this->types[$a]); + $values[$a] = $this->cast($values[$a], $this->types[$a]); // re-adjust for null casts - if($value===null) $type = \SQLITE3_NULL; + if($values[$a]===null) $type = \SQLITE3_NULL; // perform binding - $this->st->bindParam($a+1, $value, $type); + $this->st->bindParam($a+1, $values[$a], $type); } return new ResultSQLite3($this->st->execute(), $this->db->changes(), $this); }