diff --git a/lib/session_db.php b/lib/session_db.php index 10eeea149..c1771f2fa 100644 --- a/lib/session_db.php +++ b/lib/session_db.php @@ -230,14 +230,14 @@ private function acquire_lock($key) { $params = [':hash_key' => crc32($lock_name)]; break; case 'sqlite': - $query = 'UPDATE hm_user_session SET lock=1 WHERE hm_id=? AND lock=0'; - $params = [$key]; + $query = 'UPDATE hm_user_session SET lock=1 WHERE hm_id=:hm_id AND lock=0'; + $params = [':hm_id' => $key]; break; default: Hm_Debug::add('DB SESSION: Unsupported db_driver for locking: ' . $this->db_driver); return false; - } - $result = Hm_DB::execute($this->dbh, $query, $params); + } + $result = Hm_DB::execute($this->dbh, $query, $params, ($this->db_driver == 'sqlite') ? 'modify' : false); if ($this->db_driver == 'mysql') { if (isset($result['GET_LOCK(?, ?)']) && $result['GET_LOCK(?, ?)'] == 1) { return true; @@ -249,7 +249,7 @@ private function acquire_lock($key) { } } if ($this->db_driver == 'sqlite') { - if (isset($result[0]) && $result[0] == 1) { + if ($result >= 1) { return true; } } @@ -281,8 +281,8 @@ private function release_lock($key) { $params = [':hash_key' => crc32($lock_name)]; break; case 'sqlite': - $query = 'UPDATE hm_user_session SET lock=0 WHERE hm_id=?'; - $params = [$key]; + $query = 'UPDATE hm_user_session SET lock=0 WHERE hm_id=:hm_id'; + $params = [':hm_id' => $key]; break; default: Hm_Debug::add('DB SESSION: Unsupported db_driver for unlocking: ' . $this->db_driver); diff --git a/tests/phpunit/data/schema_postgres.sql b/tests/phpunit/data/schema_postgres.sql index e756a1879..8c8ce9b50 100644 --- a/tests/phpunit/data/schema_postgres.sql +++ b/tests/phpunit/data/schema_postgres.sql @@ -7,6 +7,6 @@ DROP TABLE IF EXISTS hm_user_settings; CREATE TABLE IF NOT EXISTS hm_user (username varchar(255), hash varchar(255), primary key (username)); -CREATE TABLE IF NOT EXISTS hm_user_session (hm_id varchar(255), data longblob, date timestamp, hm_version int default 1, primary key (hm_id)); +CREATE TABLE IF NOT EXISTS hm_user_session (hm_id varchar(255), data bytea, date timestamp, hm_version int default 1, primary key (hm_id)); -CREATE TABLE IF NOT EXISTS hm_user_settings(username varchar(255), settings longblob, primary key (username)); +CREATE TABLE IF NOT EXISTS hm_user_settings(username varchar(255), settings bytea, primary key (username));