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
7 changes: 6 additions & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- **💾 Open format:** Files are saved as [Markdown](https://en.wikipedia.org/wiki/Markdown), so you can edit them from any other text app too.
- **✊ Strong foundation:** We use [🐈 tiptap](https://tiptap.scrumpy.io) which is based on [🦉 ProseMirror](https://prosemirror.net) – huge thanks to them!
]]></description>
<version>3.7.1</version>
<version>3.7.2</version>
<licence>agpl</licence>
<author mail="[email protected]">Julius Härtl</author>
<namespace>Text</namespace>
Expand Down Expand Up @@ -40,4 +40,9 @@
<plugin>OCA\Text\DAV\WorkspacePlugin</plugin>
</plugins>
</sabre>
<repair-steps>
<post-migration>
<step>OCA\Text\Migration\ResetSessionsBeforeYjs</step>
</post-migration>
</repair-steps>
</info>
1 change: 1 addition & 0 deletions composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'OCA\\Text\\Listeners\\LoadViewerListener' => $baseDir . '/../lib/Listeners/LoadViewerListener.php',
'OCA\\Text\\Listeners\\NodeCopiedListener' => $baseDir . '/../lib/Listeners/NodeCopiedListener.php',
'OCA\\Text\\Listeners\\RegisterDirectEditorEventListener' => $baseDir . '/../lib/Listeners/RegisterDirectEditorEventListener.php',
'OCA\\Text\\Migration\\ResetSessionsBeforeYjs' => $baseDir . '/../lib/Migration/ResetSessionsBeforeYjs.php',
'OCA\\Text\\Migration\\Version010000Date20190617184535' => $baseDir . '/../lib/Migration/Version010000Date20190617184535.php',
'OCA\\Text\\Migration\\Version030001Date20200402075029' => $baseDir . '/../lib/Migration/Version030001Date20200402075029.php',
'OCA\\Text\\Migration\\Version030201Date20201116110353' => $baseDir . '/../lib/Migration/Version030201Date20201116110353.php',
Expand Down
1 change: 1 addition & 0 deletions composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ComposerStaticInitText
'OCA\\Text\\Listeners\\LoadViewerListener' => __DIR__ . '/..' . '/../lib/Listeners/LoadViewerListener.php',
'OCA\\Text\\Listeners\\NodeCopiedListener' => __DIR__ . '/..' . '/../lib/Listeners/NodeCopiedListener.php',
'OCA\\Text\\Listeners\\RegisterDirectEditorEventListener' => __DIR__ . '/..' . '/../lib/Listeners/RegisterDirectEditorEventListener.php',
'OCA\\Text\\Migration\\ResetSessionsBeforeYjs' => __DIR__ . '/..' . '/../lib/Migration/ResetSessionsBeforeYjs.php',
'OCA\\Text\\Migration\\Version010000Date20190617184535' => __DIR__ . '/..' . '/../lib/Migration/Version010000Date20190617184535.php',
'OCA\\Text\\Migration\\Version030001Date20200402075029' => __DIR__ . '/..' . '/../lib/Migration/Version030001Date20200402075029.php',
'OCA\\Text\\Migration\\Version030201Date20201116110353' => __DIR__ . '/..' . '/../lib/Migration/Version030201Date20201116110353.php',
Expand Down
11 changes: 11 additions & 0 deletions lib/Db/SessionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, 'text_sessions', Session::class);
}

/**
* @return array
*/
public function findAllDocuments(): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName());

return $this->findEntities($qb);
}

/**
* @param $documentId
* @param $sessionId
Expand Down
57 changes: 57 additions & 0 deletions lib/Migration/ResetSessionsBeforeYjs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace OCA\Text\Migration;

use OCA\Text\Db\SessionMapper;
use OCA\Text\Service\DocumentService;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class ResetSessionsBeforeYjs implements IRepairStep {
private IConfig $config;
private SessionMapper $sessionMapper;
private DocumentService $documentService;

public function __construct(IConfig $config,
SessionMapper $sessionMapper,
DocumentService $documentService) {
$this->config = $config;
$this->sessionMapper = $sessionMapper;
$this->documentService = $documentService;
}

/**
* @return string
*/
public function getName(): string {
return 'Force-reset all Text sessions before Yjs migration';
}

/**
* @param IOutput $output
*
* @return void
*/
public function run(IOutput $output): void {
$appVersion = $this->config->getAppValue('text', 'installed_version');

if (!$appVersion || version_compare($appVersion, '3.7.2') !== -1) {
return;
}

$sessions = $this->sessionMapper->findAllDocuments();
if (!$sessions) {
return;
}

$output->startProgress(count($sessions));
foreach ($sessions as $session) {
$documentId = $session->getDocumentId();
$this->documentService->unlock($documentId);
$this->documentService->resetDocument($documentId, true);
$output->advance();
}
$output->finishProgress();
}
}
2 changes: 1 addition & 1 deletion lib/Service/DocumentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function autosave(?File $file, int $documentId, int $version, ?string $au
* @param bool $force
* @throws DocumentHasUnsavedChangesException
*/
public function resetDocument(int $documentId, $force = false): void {
public function resetDocument(int $documentId, bool $force = false): void {
try {
$this->unlock($documentId);

Expand Down