diff --git a/lib/Command/ConvertToBigInt.php b/lib/Command/ConvertToBigInt.php index a66cffe441..b8511c14d7 100644 --- a/lib/Command/ConvertToBigInt.php +++ b/lib/Command/ConvertToBigInt.php @@ -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'], ]; diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index 89c9e08d77..4400351911 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -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(); @@ -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 : ''); } } diff --git a/lib/Db/Wopi.php b/lib/Db/Wopi.php index 82aaf25ef9..32a4a02217 100644 --- a/lib/Db/Wopi.php +++ b/lib/Db/Wopi.php @@ -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) @@ -82,7 +82,7 @@ class Wopi extends Entity implements \JsonSerializable { /** @var int */ protected $fileid; - /** @var int */ + /** @var string */ protected $version; /** @var bool */ @@ -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); diff --git a/lib/Db/WopiMapper.php b/lib/Db/WopiMapper.php index 0ed77392a0..17247d9fdb 100644 --- a/lib/Db/WopiMapper.php +++ b/lib/Db/WopiMapper.php @@ -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 diff --git a/lib/Migration/Version10000Date20251217143558.php b/lib/Migration/Version10000Date20251217143558.php new file mode 100644 index 0000000000..f4a846b240 --- /dev/null +++ b/lib/Migration/Version10000Date20251217143558.php @@ -0,0 +1,77 @@ +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 { + } +} diff --git a/lib/Migration/Version2060Date20200302131958.php b/lib/Migration/Version2060Date20200302131958.php index ec53f86874..00494892c8 100644 --- a/lib/Migration/Version2060Date20200302131958.php +++ b/lib/Migration/Version2060Date20200302131958.php @@ -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, diff --git a/src/view/Office.vue b/src/view/Office.vue index 7b42f7a88f..084f749d3f 100644 --- a/src/view/Office.vue +++ b/src/view/Office.vue @@ -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() @@ -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'),