diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e0d556..a207096 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 4fa99bc..4d0ab6c 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -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
]]>
- 1.5.2
+ 1.5.3
AGPL
Frank de Lange
diff --git a/js/ready.js b/js/ready.js
index 75686e2..3a97525 100644
--- a/js/ready.js
+++ b/js/ready.js
@@ -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);
diff --git a/lib/Db/PreferenceMapper.php b/lib/Db/PreferenceMapper.php
index 350ea00..7dcf8fe 100644
--- a/lib/Db/PreferenceMapper.php
+++ b/lib/Db/PreferenceMapper.php
@@ -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) {
diff --git a/lib/Hooks.php b/lib/Hooks.php
index 46f2e9e..91f945c 100644
--- a/lib/Hooks.php
+++ b/lib/Hooks.php
@@ -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();
}
}
diff --git a/lib/Listeners/LoadViewerListener.php b/lib/Listeners/LoadViewerListener.php
index 1678ae2..3e7dd53 100644
--- a/lib/Listeners/LoadViewerListener.php
+++ b/lib/Listeners/LoadViewerListener.php
@@ -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');
}
}
diff --git a/lib/Migration/Version013000Date202209191710407.php b/lib/Migration/Version013000Date202209191710407.php
deleted file mode 100644
index df92422..0000000
--- a/lib/Migration/Version013000Date202209191710407.php
+++ /dev/null
@@ -1,143 +0,0 @@
-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) {
- }
-}
diff --git a/lib/Migration/Version015002Date20220924183940.php b/lib/Migration/Version015003Date20220924233946.php
similarity index 80%
rename from lib/Migration/Version015002Date20220924183940.php
rename to lib/Migration/Version015003Date20220924233946.php
index 52df757..0513cfa 100644
--- a/lib/Migration/Version015002Date20220924183940.php
+++ b/lib/Migration/Version015003Date20220924233946.php
@@ -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;
}