From 4aee8fc0335e396ac0aac3983c74c710b4082d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pauli=20J=C3=A4rvinen?= Date: Fri, 3 Jan 2025 23:16:14 +0200 Subject: [PATCH] Fix background cleanup job not working on PostgreSQL In PostgreSQL, double quotes (") denote a column or table name instead of string literal. This differs from MariaDB and SQLite. refs https://github.com/owncloud/music/issues/1191 --- CHANGELOG.md | 6 ++++++ lib/Db/Maintenance.php | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 766a71a7a..a3be44dcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [Unreleased] + +### Fixed +- Background cleanup job not working with PostgreSQL (since v2.1.0) + [#1191](https://github.com/owncloud/music/issues/1191) + ## 2.1.0 - 2025-01-02 ### Added diff --git a/lib/Db/Maintenance.php b/lib/Db/Maintenance.php index 88e6671fc..ec501558c 100644 --- a/lib/Db/Maintenance.php +++ b/lib/Db/Maintenance.php @@ -34,7 +34,7 @@ public function __construct(IDBConnection $db, Logger $logger) { */ private function removeStrayScanningStatus() : int { $sql = 'SELECT `user_id`, `data` FROM `*PREFIX*music_cache` - WHERE `key` = "scanning"'; + WHERE `key` = \'scanning\''; $result = $this->db->executeQuery($sql); $rows = $result->fetchAll(); $result->closeCursor(); @@ -45,7 +45,7 @@ private function removeStrayScanningStatus() : int { $timestamp = (int)$row['data']; if ($now - $timestamp > 60) { $modRows += $this->db->executeUpdate( - 'DELETE FROM `*PREFIX*music_cache` WHERE `key` = "scanning" AND `user_id` = ?', + 'DELETE FROM `*PREFIX*music_cache` WHERE `key` = \'scanning\' AND `user_id` = ?', [$row['user_id']] ); } @@ -58,7 +58,7 @@ private function removeStrayScanningStatus() : int { * @return bool true if at least one user has an ongoing scanning job */ private function scanningInProgress() : bool { - $sql = 'SELECT 1 FROM `*PREFIX*music_cache` WHERE `key` = "scanning"'; + $sql = 'SELECT 1 FROM `*PREFIX*music_cache` WHERE `key` = \'scanning\''; $result = $this->db->executeQuery($sql); $row = $result->fetch(); return (bool)$row;