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
2 changes: 1 addition & 1 deletion lib/Command/ConvertToBigInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function configure() {

protected function getColumnsByTable() {
return [
'richdocuments_wopi' => ['id', 'fileid', 'version', 'template_id', 'template_destination', 'expiry'],
'richdocuments_wopi' => ['id', 'fileid', 'template_id', 'template_destination', 'expiry'],
'richdocuments_direct' => ['id', 'fileid', 'template_id', 'template_destination', 'timestamp'],
'richdocuments_assets' => ['id', 'fileid', 'timestamp'],
];
Expand Down
5 changes: 2 additions & 3 deletions lib/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ private function getFileForShare(IShare $share, ?int $fileId, ?string $path = nu
throw new NotFoundException();
}

private function getToken(File $file, ?IShare $share = null, ?int $version = null, bool $isGuest = false): Wopi {
// Pass through $version
private function getToken(File $file, ?IShare $share = null, ?string $version = null, bool $isGuest = false): Wopi {
$templateFile = $this->templateManager->getTemplateSource($file->getId());
if ($templateFile) {
$owneruid = $share?->getShareOwner() ?? $file->getOwner()->getUID();
Expand All @@ -520,7 +519,7 @@ private function getToken(File $file, ?IShare $share = null, ?int $version = nul
return $this->tokenManager->generateWopiToken($this->getWopiFileId($file->getId(), $version), $share?->getToken(), $this->userId);
}

private function getWopiFileId(int $fileId, ?int $version = null): string {
private function getWopiFileId(int $fileId, ?string $version = null): string {
return $fileId . '_' . $this->config->getSystemValue('instanceid') . ($version ? '_' . $version : '');
}
}
8 changes: 4 additions & 4 deletions lib/Db/Wopi.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* @method string getEditorUid()
* @method void setFileid(int $fileid)
* @method int getFileid()
* @method void setVersion(int $version)
* @method int getVersion()
* @method void setVersion(string $version)
* @method string getVersion()
* @method void setCanwrite(bool $canwrite)
* @method bool getCanwrite()
* @method void setServerHost(string $host)
Expand Down Expand Up @@ -82,7 +82,7 @@ class Wopi extends Entity implements \JsonSerializable {
/** @var int */
protected $fileid;

/** @var int */
/** @var string */
protected $version;

/** @var bool */
Expand Down Expand Up @@ -128,7 +128,7 @@ public function __construct() {
$this->addType('ownerUid', Types::STRING);
$this->addType('editorUid', Types::STRING);
$this->addType('fileid', Types::INTEGER);
$this->addType('version', Types::INTEGER);
$this->addType('version', Types::STRING);
$this->addType('canwrite', Types::BOOLEAN);
$this->addType('serverHost', Types::STRING);
$this->addType('token', Types::STRING);
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/WopiMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
* @param int $fileId
* @param string $owner
* @param string $editor
* @param int $version
* @param string $version
* @param bool $updatable
* @param string $serverHost
* @param string $guestDisplayname
Expand Down
77 changes: 77 additions & 0 deletions lib/Migration/Version10000Date20251217143558.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Richdocuments\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;

/**
* Update version column in richdocuments_wopi table to support alphanumeric versions
*/
class Version10000Date20251217143558 extends SimpleMigrationStep {

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
#[Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
* @return null|ISchemaWrapper
*/
#[Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if (!$schema->hasTable('richdocuments_wopi')) {
return null;
}

$table = $schema->getTable('richdocuments_wopi');

if (!$table->hasColumn('version')) {
return null;
}

$column = $table->getColumn('version');

if ($column->getType()->getName() === 'string') {
return null;
}

$table->changeColumn('version', [
'type' => 'string',
'notnull' => false,
'length' => 1024,
'default' => '0',
]);

return $schema;
}

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
#[Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
}
7 changes: 3 additions & 4 deletions lib/Migration/Version2060Date20200302131958.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
'notnull' => true,
'length' => 20,
]);
$table->addColumn('version', 'bigint', [
//'notnull' => true,
$table->addColumn('version', 'string', [
'notnull' => false,
'length' => 20,
'default' => 0,
'length' => 1024,
'default' => '0',
]);
$table->addColumn('canwrite', 'boolean', [
//'notnull' => true,
Expand Down
6 changes: 3 additions & 3 deletions src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default {
methods: {
async load() {
const fileid = this.fileid ?? basename(dirname(this.source))
const version = this.fileid ? 0 : basename(this.source)
const version = this.fileid ? '0' : basename(this.source)

enableScrollLock()

Expand All @@ -330,8 +330,8 @@ export default {

// Generate form and submit to the iframe
const action = getWopiUrl({
fileId: fileid + '_' + loadState('richdocuments', 'instanceId', 'instanceid') + (version > 0 ? '_' + version : ''),
readOnly: forceReadOnly || version > 0,
fileId: fileid + '_' + loadState('richdocuments', 'instanceId', 'instanceid') + (version && version !== '0' ? '_' + version : ''),
readOnly: forceReadOnly || (version && version !== '0'),
revisionHistory: !this.isPublic,
closeButton: !Config.get('hideCloseButton') && !this.isEmbedded,
startPresentation: Config.get('startPresentation'),
Expand Down
Loading