Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [Unreleased]

### Added
- Support for ownCloud 11 (tested on 11.0.0-prealpha)

### Fixed
- Deprecation warnings printed on PHP 8.3+ while executing the Music background tasks
- Web UI trying to load an invalid image URL upon page load

## 2.5.2 - 2026-05-10

### Changed
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<repository type="git">https://github.com/owncloud/music.git</repository>
<dependencies>
<php min-version="7.4" max-version="8.4"/>
<owncloud min-version="10.5" max-version="10" />
<owncloud min-version="10.5" max-version="11" />
<nextcloud min-version="20" max-version="32" />
</dependencies>
<types>
Expand Down
19 changes: 9 additions & 10 deletions lib/AppFramework/Db/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getTableName() {
public function delete(Entity $entity) {
$sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?';
$stmt = $this->execute($sql, [$entity->getId()]);
$stmt->closeCursor();
$stmt->free();
return $entity;
}

Expand Down Expand Up @@ -135,7 +135,7 @@ public function insert(Entity $entity) {

$entity->setId((int) $this->db->lastInsertId($this->tableName));

$stmt->closeCursor();
$stmt->free();

return $entity;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ public function update(Entity $entity) {
$params[] = $id;

$stmt = $this->execute($sql, $params);
$stmt->closeCursor();
$stmt->free();

return $entity;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ private function getPDOType($value) {
* @param array $params the params which should replace the ? in the sql query
* @param int $limit the maximum number of rows
* @param int $offset from which row we want to start
* @return \Doctrine\DBAL\Driver\Statement the database query result
* @return mixed the database query result (depending on the Doctrine DBAL version, this can be either a Statement or a Result)
* @since 7.0.0
*/
protected function execute($sql, array $params=[], $limit=null, $offset=null) {
Expand All @@ -252,9 +252,8 @@ protected function execute($sql, array $params=[], $limit=null, $offset=null) {
}
}

$query->execute();

return $query;
$result = $query->execute();
return \is_bool($result) ? $query : $result;
}

/**
Expand All @@ -275,7 +274,7 @@ protected function findOneQuery($sql, array $params=[], $limit=null, $offset=nul
$row = $stmt->fetch();

if ($row === false || $row === null) {
$stmt->closeCursor();
$stmt->free();
$msg = $this->buildDebugMessage(
'Did expect one result but found none when executing',
$sql,
Expand All @@ -286,7 +285,7 @@ protected function findOneQuery($sql, array $params=[], $limit=null, $offset=nul
throw new DoesNotExistException($msg);
}
$row2 = $stmt->fetch();
$stmt->closeCursor();
$stmt->free();
//MDB2 returns null, PDO and doctrine false when no row is available
if (! ($row2 === false || $row2 === null)) {
$msg = $this->buildDebugMessage(
Expand Down Expand Up @@ -353,7 +352,7 @@ protected function findEntities($sql, array $params=[], $limit=null, $offset=nul
$entities[] = $this->mapRowToEntity($row);
}

$stmt->closeCursor();
$stmt->free();

return $entities;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/BackgroundJob/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Morris Jobke <hey@morrisjobke.de>
* @author Pauli Järvinen <pauli.jarvinen@gmail.com>
* @copyright Morris Jobke 2013, 2014
* @copyright Pauli Järvinen 2017 - 2025
* @copyright Pauli Järvinen 2017 - 2026
*/

namespace OCA\Music\BackgroundJob;
Expand All @@ -32,7 +32,7 @@ public function run($arguments) {
$app = \OC::$server->query(Application::class);

$logger = $app->get(Logger::class);
$logger->debug('Run ' . \get_class());
$logger->debug('Run ' . static::class);

// remove orphaned entities
$app->get(Maintenance::class)->cleanUp();
Expand Down
4 changes: 2 additions & 2 deletions lib/BackgroundJob/PodcastUpdateCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* later. See the COPYING file.
*
* @author Pauli Järvinen <pauli.jarvinen@gmail.com>
* @copyright Pauli Järvinen 2021 - 2025
* @copyright Pauli Järvinen 2021 - 2026
*/

namespace OCA\Music\BackgroundJob;
Expand All @@ -30,7 +30,7 @@ public function run($arguments) {
$app = \OC::$server->query(Application::class);

$logger = $app->get(Logger::class);
$logger->debug('Run ' . \get_class());
$logger->debug('Run ' . static::class);

$minInterval = (float)$app->get(IConfig::class)->getSystemValue('music.podcast_auto_update_interval', 24); // hours
// negative interval values can be used to disable the auto-update
Expand Down
12 changes: 3 additions & 9 deletions lib/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* later. See the COPYING file.
*
* @author Pauli Järvinen <pauli.jarvinen@gmail.com>
* @copyright Pauli Järvinen 2018 - 2025
* @copyright Pauli Järvinen 2018 - 2026
*/

namespace OCA\Music\Command;
Expand All @@ -28,10 +28,7 @@ public function __construct(\OCP\IUserManager $userManager, \OCP\IGroupManager $
parent::__construct();
}

/**
* @return void
*/
protected function configure() {
protected function configure() : void {
$this
->addArgument(
'user_id',
Expand All @@ -54,10 +51,7 @@ protected function configure() {
$this->doConfigure();
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output) : int {
try {
self::ensureUsersGiven($input);
$argUsers = $this->getArgumentUsers($input);
Expand Down
12 changes: 3 additions & 9 deletions lib/Command/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* later. See the COPYING file.
*
* @author Pauli Järvinen <pauli.jarvinen@gmail.com>
* @copyright Pauli Järvinen 2017 - 2025
* @copyright Pauli Järvinen 2017 - 2026
*/

namespace OCA\Music\Command;
Expand All @@ -26,20 +26,14 @@ public function __construct(Maintenance $maintenance) {
parent::__construct();
}

/**
* @return void
*/
protected function configure() {
protected function configure() : void {
$this
->setName('music:cleanup')
->setDescription('clean up orphaned DB entries (this happens also periodically on the background)')
;
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output) : int {
$output->writeln('Running cleanup task...');
$removedEntries = $this->maintenance->cleanUp();
$output->writeln("Removed entries: " . \json_encode($removedEntries));
Expand Down
4 changes: 2 additions & 2 deletions lib/Command/RegisterMimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(IMimeTypeLoader $mimeTypeLoader) {
/**
* @return void
*/
protected function configure() {
protected function configure() : void {
$this
->setName('music:register-mime-types')
->setDescription('map following file extensions to proper MIME types: ' . \json_encode(\array_keys($this->mimeMappings)));
Expand All @@ -49,7 +49,7 @@ protected function configure() {
/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output) : int {
try {
$output->writeln('Registering MIME types for existing files...');
$this->registerForExistingFiles($output);
Expand Down
30 changes: 15 additions & 15 deletions lib/Db/AlbumMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getPerformingArtistsByAlbumId(?array $albumIds, string $userId)
while ($row = $result->fetch()) {
$artistIds[$row['album_id']][] = (int)$row['artist_id'];
}
$result->closeCursor();
$result->free();
return $artistIds;
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public function getYearsByAlbumId(?array $albumIds, string $userId) : array {
while ($row = $result->fetch()) {
$years[$row['album_id']][] = (int)$row['year'];
}
$result->closeCursor();
$result->free();
return $years;
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public function getGenresByAlbumId(?array $albumIds, string $userId) : array {
$genre->setName($row['genre_name']);
$genres[$row['album_id']][] = $genre;
}
$result->closeCursor();
$result->free();
return $genres;
}

Expand Down Expand Up @@ -174,7 +174,7 @@ public function getDiscCountByAlbumId(?array $albumIds, string $userId) : array
while ($row = $result->fetch()) {
$diskCountByAlbum[$row['album_id']] = (int)$row['disc_count'];
}
$result->closeCursor();
$result->free();
return $diskCountByAlbum;
}

Expand All @@ -195,7 +195,7 @@ public function getAlbumTracksPlayCount(string $userId, ?int $limit=null, ?int $
while ($row = $result->fetch()) {
$playCountByAlbum[$row['album_id']] = (int)$row['sum_count'];
}
$result->closeCursor();
$result->free();
return $playCountByAlbum;
}

Expand All @@ -216,7 +216,7 @@ public function getLatestAlbumPlayTimes(string $userId, ?int $limit=null, ?int $
while ($row = $result->fetch()) {
$latestTimeByAlbum[$row['album_id']] = $row['latest_time'];
}
$result->closeCursor();
$result->free();
return $latestTimeByAlbum;
}

Expand All @@ -238,7 +238,7 @@ public function getFurthestAlbumPlayTimes(string $userId, ?int $limit=null, ?int
while ($row = $result->fetch()) {
$latestTimeByAlbum[$row['album_id']] = $row['latest_time'];
}
$result->closeCursor();
$result->free();
return $latestTimeByAlbum;
}

Expand Down Expand Up @@ -314,7 +314,7 @@ public function updateFolderCover(int $coverFileId, int $folderId) : bool {
$params = [$folderId];
$result = $this->execute($sql, $params);
$albumIds = $result->fetchAll(\PDO::FETCH_COLUMN);
$result->closeCursor();
$result->free();

$updated = false;
if (\count($albumIds) > 0) {
Expand All @@ -324,7 +324,7 @@ public function updateFolderCover(int $coverFileId, int $folderId) : bool {
$params = \array_merge([$coverFileId], $albumIds);
$result = $this->execute($sql, $params);
$updated = $result->rowCount() > 0;
$result->closeCursor();
$result->free();
}

return $updated;
Expand All @@ -339,7 +339,7 @@ public function setCover(?int $coverFileId, int $albumId) : void {
WHERE `id` = ?';
$params = [$coverFileId, $albumId];
$result = $this->execute($sql, $params);
$result->closeCursor();
$result->free();
}

/**
Expand Down Expand Up @@ -367,7 +367,7 @@ public function removeCovers(array $coverFileIds, ?array $userIds=null) : array
WHERE `id` IN ' . $this->questionMarks($count);
$params = ArrayUtil::extractIds($albums);
$result = $this->execute($sql, $params);
$result->closeCursor();
$result->free();
}

return $albums;
Expand Down Expand Up @@ -403,7 +403,7 @@ public function getAlbumsWithoutCover(?string $userId = null, ?array $parentIds
'parentFolderId' => (int)$row['parent']
];
}
$result->closeCursor();
$result->free();

return $return;
}
Expand All @@ -420,7 +420,7 @@ public function findAlbumCover(int $albumId, int $parentFolderId) : bool {
$params = [$parentFolderId];
$result = $this->execute($imagesSql, $params);
$images = $result->fetchAll();
$result->closeCursor();
$result->free();
if (\count($images) > 0) {
$getImageRank = function($imageName) {
$coverNames = ['cover', 'albumart', 'album', 'front', 'folder'];
Expand Down Expand Up @@ -478,7 +478,7 @@ public function countByArtist(int $artistId) : int {
$params = [$artistId, $artistId];
$result = $this->execute($sql, $params);
$row = $result->fetch();
$result->closeCursor();
$result->free();
return (int)$row['count'];
}

Expand All @@ -494,7 +494,7 @@ public function countByAlbumArtist(int $artistId) : int {
$params = [$artistId];
$result = $this->execute($sql, $params);
$row = $result->fetch();
$result->closeCursor();
$result->free();
return (int)$row['count'];
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Db/AmpacheSessionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ public function extend(string $token, int $expiry) : void {

$params = [$expiry, $token];
$result = $this->execute($sql, $params);
$result->closeCursor();
$result->free();
}

public function cleanUp() : void {
$sql = 'DELETE FROM `*PREFIX*music_ampache_sessions`
WHERE `expiry` < ?';
$params = [\time()];
$result = $this->execute($sql, $params);
$result->closeCursor();
$result->free();
}

public function revokeSessions(int $ampacheUserId) : void {
$sql = 'DELETE FROM `*PREFIX*music_ampache_sessions`
WHERE `ampache_user_id` = ?';
$params = [$ampacheUserId];
$result = $this->execute($sql, $params);
$result->closeCursor();
$result->free();
}
}
Loading