- Revert to oc_reader_prefs to avoid problem with "too long index name", this undoes the change in 1.5.2.

- reduce maximum database string column size to 3999 to get around '4000 length limit' (https://github.com/nextcloud/server/issues/31791)
This commit is contained in:
Frank de Lange 2022-09-24 22:14:54 +00:00
parent 5e20a5b7ce
commit d875ae571b
8 changed files with 30 additions and 179 deletions

View file

@ -1,6 +1,11 @@
## 1.5.3 - 2022-08-24
### Fixed
- Revert to oc_reader_prefs to avoid problem with "too long index name", this undoes the change in 1.5.2.
- reduce maximum database string column size to 3999 to get around '4000 length limit' (https://github.com/nextcloud/server/issues/31791)
## 1.5.2 - 2022-08-24
### Fixed
- Typo in (database) Migrations kept Reader working for those who did not already have the correct table in their database
- Typo in (database) Migrations kept Reader from working for those who did not already have the correct table in their database
## 1.5.1 - 2022-08-24
### Fixed

View file

@ -30,7 +30,7 @@ See [README] for more exhaustive information on features and potential misfeatur
[README]: https://github.com/Yetangitu/owncloud-apps/blob/master/files_reader/README.md
]]>
</description>
<version>1.5.2</version>
<version>1.5.3</version>
<licence>AGPL</licence>
<author>Frank de Lange</author>
<documentation>

View file

@ -25,9 +25,6 @@ document.onreadystatechange = function () {
options.session.basePath = $session.data('basepath');
options.session.downloadLink = $session.data('downloadlink');
console.log(options.session.basePath);
/* functions return jquery promises */
options.session.getPreference = function(name) {
return $.get(options.session.basePath + "preference/" + options.session.fileId + "/" + options.session.scope + "/" + name);

View file

@ -16,12 +16,12 @@ use OCP\IDBConnection;
class PreferenceMapper extends ReaderMapper {
public function __construct(IDBConnection $db, $UserId, Time $time) {
parent::__construct($db, 'reader_preferences', Preference::class, $time);
parent::__construct($db, 'reader_prefs', Preference::class, $time);
$this->userId = $UserId;
}
/**
* @brief get preferences for $scope+$fileId+$userId(+$name)
* @brief get prefs for $scope+$fileId+$userId(+$name)
*
* @param string $scope
* @param int $fileId
@ -30,14 +30,14 @@ class PreferenceMapper extends ReaderMapper {
*/
public function get($scope, $fileId, $name=null) {
if(!empty($name)) {
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE `scope`=? AND `file_id`=? AND `user_id`=? AND `name`=?";
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE `scope`=? AND `file_id`=? AND `user_id`=? AND `name`=?";
$args = array(
$scope,
$fileId,
$this->userId,
$name);
} else {
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE `scope`=? AND `file_id`=? AND `user_id`=?";
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE `scope`=? AND `file_id`=? AND `user_id`=?";
$args = array(
$scope,
$fileId,
@ -83,7 +83,7 @@ class PreferenceMapper extends ReaderMapper {
/* currently not used*/
public function deleteForFileId($fileId) {
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE file_id=?";
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE file_id=?";
$args = [ $fileId ];
array_map(
function($entity) {
@ -94,7 +94,7 @@ class PreferenceMapper extends ReaderMapper {
/* currently not used*/
public function deleteForUserId($userId) {
$sql = "SELECT * FROM `*PREFIX*reader_preferences` WHERE user_id=?";
$sql = "SELECT * FROM `*PREFIX*reader_prefs` WHERE user_id=?";
$args = [ $userId ];
array_map(
function($entity) {

View file

@ -33,7 +33,7 @@ class Hooks {
$queryBuilder->execute();
$queryBuilder = $connection->getQueryBuilder();
$queryBuilder->delete('reader_preferences')->where('file_id = :file_id')->setParameter(':file_id', $fileId);
$queryBuilder->delete('reader_prefs')->where('file_id = :file_id')->setParameter(':file_id', $fileId);
$queryBuilder->execute();
}
@ -43,7 +43,7 @@ class Hooks {
$queryBuilder->execute();
$queryBuilder = $connection->getQueryBuilder();
$queryBuilder->delete('reader_preferences')->where('user_id = :user_id')->setParameter(':user_id', $userId);
$queryBuilder->delete('reader_prefs')->where('user_id = :user_id')->setParameter(':user_id', $userId);
$queryBuilder->execute();
}
}

View file

@ -43,9 +43,9 @@ class LoadViewerListener implements IEventListener {
if (!($event instanceof LoadViewer || $event instanceof LoadAdditionalScriptsEvent)) {
return;
}
$this->initialStateService->provideInitialState('epub_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'epub_enable'));
$this->initialStateService->provideInitialState('pdf_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'pdf_enable'));
$this->initialStateService->provideInitialState('cbx_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'cbx_enable'));
$this->initialStateService->provideInitialState('epub_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'epub_enable', 'true'));
$this->initialStateService->provideInitialState('pdf_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'pdf_enable', 'true'));
$this->initialStateService->provideInitialState('cbx_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'cbx_enable', 'true'));
Util::addScript(Application::APP_ID, 'plugin');
}
}

View file

@ -1,143 +0,0 @@
<?php
declare(strict_types=1);
namespace OCA\Files_Reader\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step
*/
class Version013000Date202209191710407 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('reader_bookmarks')) {
$table = $schema->createTable('reader_bookmarks');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 8,
'unsigned' => true,
]);
// user ID, maps bookmark to NC/OC user
$table->addColumn('user_id', 'string', [
'notnull' => true,
'length' => 64,
'default' => '',
]);
// file ID, maps to NC/OC file ID
$table->addColumn('file_id', 'bigint', [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
// type (bookmark, annotation, etc)
$table->addColumn('type', 'string', [
'notnull' => true,
'length' => 32,
'default' => '',
]);
$table->addColumn('name', 'string', [
'notnull' => true,
'length' => 512,
'default' => '',
]);
$table->addColumn('value', 'string', [
'notnull' => true,
'length' => 512,
'default' => '',
]);
$table->addColumn('content', 'string', [
'notnull' => false,
'length' => 4096,
]);
$table->addColumn('last_modified', 'bigint', [
'notnull' => false,
'length' => 8,
'default' => 0,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['file_id'], 'reader_bookmarks_file_id_index');
$table->addIndex(['user_id'], 'reader_bookmarks_user_id_index');
$table->addIndex(['name'], 'reader_bookmarks_name_index');
}
if (!$schema->hasTable('reader_prefs')) {
$table = $schema->createTable('reader_prefs');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 8,
'unsigned' => true,
]);
// user ID, maps preference to NC/OC user
$table->addColumn('user_id', 'string', [
'notnull' => true,
'length' => 64,
'default' => '',
]);
// file ID, maps to NC/OC file ID
$table->addColumn('file_id', 'bigint', [
'notnull' => true,
'length' => 11,
'unsigned' => true,
]);
$table->addColumn('scope', 'string', [
'notnull' => true,
'length' => 32,
'default' => '',
]);
$table->addColumn('name', 'string', [
'notnull' => true,
'length' => 128,
'default' => '',
]);
$table->addColumn('value', 'string', [
'notnull' => true,
'length' => 4096,
'default' => '',
]);
$table->addColumn('last_modified', 'bigint', [
'notnull' => false,
'length' => 8,
'default' => 0,
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['file_id'], 'reader_prefs_file_id_index');
$table->addIndex(['user_id'], 'reader_prefs_user_id_index');
$table->addIndex(['scope'], 'reader_prefs_scope_index');
}
return $schema;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}
}

View file

@ -12,7 +12,7 @@ use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step
*/
class Version015002Date20220924183940 extends SimpleMigrationStep {
class Version015003Date20220924233946 extends SimpleMigrationStep {
/**
* @param IOutput $output
@ -40,13 +40,13 @@ class Version015002Date20220924183940 extends SimpleMigrationStep {
'length' => 8,
'unsigned' => true,
]);
// user ID, maps bookmark to NC/OC user
// user ID, maps bookmark to NC user
$table->addColumn('user_id', 'string', [
'notnull' => true,
'length' => 64,
'default' => '',
]);
// file ID, maps to NC/OC file ID
// file ID, maps to NC file ID
$table->addColumn('file_id', 'bigint', [
'notnull' => true,
'length' => 11,
@ -70,7 +70,7 @@ class Version015002Date20220924183940 extends SimpleMigrationStep {
]);
$table->addColumn('content', 'string', [
'notnull' => false,
'length' => 4096,
'length' => 3999,
]);
$table->addColumn('last_modified', 'bigint', [
'notnull' => false,
@ -84,21 +84,21 @@ class Version015002Date20220924183940 extends SimpleMigrationStep {
$table->addIndex(['name'], 'reader_bookmarks_name_index');
}
if (!$schema->hasTable('reader_preferences')) {
$table = $schema->createTable('reader_preferences');
if (!$schema->hasTable('reader_prefs')) {
$table = $schema->createTable('reader_prefs');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 8,
'unsigned' => true,
]);
// user ID, maps preference to NC/OC user
// user ID, maps preference to NC user
$table->addColumn('user_id', 'string', [
'notnull' => true,
'length' => 64,
'default' => '',
]);
// file ID, maps to NC/OC file ID
// file ID, maps to NC file ID
$table->addColumn('file_id', 'bigint', [
'notnull' => true,
'length' => 11,
@ -116,7 +116,7 @@ class Version015002Date20220924183940 extends SimpleMigrationStep {
]);
$table->addColumn('value', 'string', [
'notnull' => true,
'length' => 4096,
'length' => 3999,
'default' => '',
]);
$table->addColumn('last_modified', 'bigint', [
@ -126,17 +126,9 @@ class Version015002Date20220924183940 extends SimpleMigrationStep {
'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['file_id'], 'reader_preferences_file_id_index');
$table->addIndex(['user_id'], 'reader_preferences_user_id_index');
$table->addIndex(['scope'], 'reader_preferences_scope_index');
}
if ($schema->hasTable('reader_prefs')) {
$table = $schema->getTable('reader_prefs');
$table->dropIndex('reader_prefs_file_id_index');
$table->dropIndex('reader_prefs_user_id_index');
$table->dropIndex('reader_prefs_scope_index');
$schema->dropTable('reader_prefs');
$table->addIndex(['file_id'], 'reader_prefs_file_id_index');
$table->addIndex(['user_id'], 'reader_prefs_user_id_index');
$table->addIndex(['scope'], 'reader_prefs_scope_index');
}
return $schema;
}