Skip to content

Commit 4675d16

Browse files
committed
fix(database): add index for wopi expiry column
Signed-off-by: Elizabeth Danzberger <elizabeth@elzody.dev>
1 parent 9795a0a commit 4675d16

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

lib/AppInfo/Application.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use OCA\Richdocuments\Db\WopiMapper;
1717
use OCA\Richdocuments\Listener\AddContentSecurityPolicyListener;
1818
use OCA\Richdocuments\Listener\AddFeaturePolicyListener;
19+
use OCA\Richdocuments\Listener\AddMissingIndicesListener;
1920
use OCA\Richdocuments\Listener\AddSabrePluginListener;
2021
use OCA\Richdocuments\Listener\BeforeFetchPreviewListener;
2122
use OCA\Richdocuments\Listener\BeforeGetTemplatesListener;
@@ -48,6 +49,7 @@
4849
use OCP\BeforeSabrePubliclyLoadedEvent;
4950
use OCP\Collaboration\Reference\RenderReferenceEvent;
5051
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent;
52+
use OCP\DB\Events\AddMissingIndicesEvent;
5153
use OCP\Files\Storage\IStorage;
5254
use OCP\Files\Template\BeforeGetTemplatesEvent;
5355
use OCP\Files\Template\FileCreatedFromTemplateEvent;
@@ -85,6 +87,7 @@ public function register(IRegistrationContext $context): void {
8587
$context->registerEventListener(OverwritePublicSharePropertiesEvent::class, OverwritePublicSharePropertiesListener::class);
8688
$context->registerEventListener(SabrePluginAddEvent::class, AddSabrePluginListener::class);
8789
$context->registerEventListener(BeforeSabrePubliclyLoadedEvent::class, AddSabrePluginListener::class);
90+
$context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class);
8891
$context->registerReferenceProvider(OfficeTargetReferenceProvider::class);
8992
$context->registerSensitiveMethods(WopiMapper::class, [
9093
'getPathForToken',
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\Richdocuments\Listener;
11+
12+
use OCP\DB\Events\AddMissingIndicesEvent;
13+
use OCP\EventDispatcher\Event;
14+
use OCP\EventDispatcher\IEventListener;
15+
16+
/**
17+
* @template-implements IEventListener<AddMissingIndicesEvent>
18+
*/
19+
class AddMissingIndicesListener implements IEventListener {
20+
#[\Override]
21+
public function handle(Event $event): void {
22+
if (!($event instanceof AddMissingIndicesEvent)) {
23+
return;
24+
}
25+
26+
/**
27+
* Added to @see Version2060Date20200302131958
28+
*/
29+
$event->addMissingIndex(
30+
'richdocuments_wopi',
31+
'rd_wopi_expiry_idx',
32+
['expiry']
33+
);
34+
}
35+
}

lib/Migration/Version2060Date20200302131958.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
133133
]);
134134
$table->setPrimaryKey(['id']);
135135
$table->addUniqueIndex(['token'], 'rd_wopi_token_idx');
136+
$table->addIndex(['expiry'], 'rd_wopi_expiry_idx');
136137
}
137138

138139
if (!$schema->hasTable('richdocuments_direct')) {

0 commit comments

Comments
 (0)