Skip to content
Merged
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
3 changes: 1 addition & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public function register(IRegistrationContext $context): void {
});

$context->registerService(VersionsBackend::class, function (ContainerInterface $c) {
$appManager = $c->get(IAppManager::class);
if ($appManager->isEnabledForUser('files_versions')) {
if (interface_exists(IVersionBackend::class)) {
return new VersionsBackend(
$c->get(CollectiveFolderManager::class),
$c->get(ITimeFactory::class),
Expand Down
16 changes: 10 additions & 6 deletions lib/BackgroundJob/ExpirePageTrash.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
class ExpirePageTrash extends TimedJob {
private Expiration $expiration;
private PageTrashBackend $trashBackend;
private bool $hasTrashBackend = false;

public function __construct(
ITimeFactory $time,
Expiration $expiration,
PageTrashBackend $trashBackend) {
ITimeFactory $time) {
Comment on lines -19 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with nextcloud 28 you could actually make them nullable, but good as it is as we cover more versions ;)

nextcloud/server#41265

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, that's great to learn. Not for now, but one day we'll drop support for everything below 28 😊

parent::__construct($time);

// Run once per hour
$this->setInterval(60 * 60);

$this->expiration = $expiration;
$this->trashBackend = $trashBackend;
if (class_exists(Expiration::class)) {
$this->hasTrashBackend = true;
$this->expiration = \OCP\Server::get(Expiration::class);
$this->trashBackend = \OCP\Server::get(PageTrashBackend::class);
}
}

/**
Expand All @@ -35,6 +37,8 @@ public function __construct(
* @throws NotPermittedException
*/
protected function run($argument): void {
$this->trashBackend->expire($this->expiration);
if ($this->hasTrashBackend) {
$this->trashBackend->expire($this->expiration);
}
}
}