Skip to content

Commit e593f32

Browse files
elzodybackportbot[bot]
authored andcommitted
fix(database): add index for wopi expiry column
Signed-off-by: Elizabeth Danzberger <elizabeth@elzody.dev>
1 parent f7bd5da commit e593f32

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;
@@ -57,6 +58,7 @@
5758
use OCP\BeforeSabrePubliclyLoadedEvent;
5859
use OCP\Collaboration\Reference\RenderReferenceEvent;
5960
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent;
61+
use OCP\DB\Events\AddMissingIndicesEvent;
6062
use OCP\DirectEditing\RegisterDirectEditorEvent;
6163
use OCP\Files\Storage\IStorage;
6264
use OCP\Files\Template\BeforeGetTemplatesEvent;
@@ -97,6 +99,7 @@ public function register(IRegistrationContext $context): void {
9799
$context->registerEventListener(OverwritePublicSharePropertiesEvent::class, OverwritePublicSharePropertiesListener::class);
98100
$context->registerEventListener(SabrePluginAddEvent::class, AddSabrePluginListener::class);
99101
$context->registerEventListener(BeforeSabrePubliclyLoadedEvent::class, AddSabrePluginListener::class);
102+
$context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class);
100103
$context->registerReferenceProvider(OfficeTargetReferenceProvider::class);
101104
$context->registerSensitiveMethods(WopiMapper::class, [
102105
'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
@@ -135,6 +135,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
135135
]);
136136
$table->setPrimaryKey(['id']);
137137
$table->addUniqueIndex(['token'], 'rd_wopi_token_idx');
138+
$table->addIndex(['expiry'], 'rd_wopi_expiry_idx');
138139
}
139140

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

0 commit comments

Comments
 (0)