Skip to content

Commit

Permalink
Fix background cleanup job not working on PostgreSQL
Browse files Browse the repository at this point in the history
In PostgreSQL, double quotes (") denote a column or table name instead of
string literal. This differs from MariaDB and SQLite.

refs #1191
  • Loading branch information
paulijar committed Jan 3, 2025
1 parent f0d52d0 commit 4aee8fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/Db/Maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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']]
);
}
Expand All @@ -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;
Expand Down

0 comments on commit 4aee8fc

Please # to comment.