summaryrefslogtreecommitdiffstats
path: root/lib/repair
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-09-09 15:18:57 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-09-10 10:22:40 +0200
commit8e2acb148243d494f2c6ccb655f904f2261870f5 (patch)
tree4ef328c964ae146b17b89c4342dc2ae8d5878e9d /lib/repair
parentdc99fd768ac99c380f1110c7bd4dd84d03256cd8 (diff)
downloadnextcloud-server-8e2acb148243d494f2c6ccb655f904f2261870f5.tar.gz
nextcloud-server-8e2acb148243d494f2c6ccb655f904f2261870f5.zip
repair search lucene before installing
Diffstat (limited to 'lib/repair')
-rw-r--r--lib/repair/innodb.php2
-rw-r--r--lib/repair/searchlucenetables.php63
2 files changed, 64 insertions, 1 deletions
diff --git a/lib/repair/innodb.php b/lib/repair/innodb.php
index 6b795a749e9..0e13c30be95 100644
--- a/lib/repair/innodb.php
+++ b/lib/repair/innodb.php
@@ -23,7 +23,7 @@ class InnoDB extends BasicEmitter implements \OC\RepairStep {
public function run() {
$connection = \OC_DB::getConnection();
if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) {
- $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to no'));
+ $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to do'));
return;
}
diff --git a/lib/repair/searchlucenetables.php b/lib/repair/searchlucenetables.php
new file mode 100644
index 00000000000..32231e9a1d3
--- /dev/null
+++ b/lib/repair/searchlucenetables.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Copyright (c) 2014 Jörn Friedrich Dreyer <jfd@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Repair;
+
+use OC\Hooks\BasicEmitter;
+
+class SearchLuceneTables extends BasicEmitter implements \OC\RepairStep {
+
+ public function getName() {
+ return 'Repair duplicate entries in oc_lucene_status';
+ }
+
+ /**
+ * Fix duplicate entries in oc_lucene_status
+ *
+ * search_lucene prior to v0.5.0 did not have a primary key on the lucene_status table. Newer versions do, which
+ * causes the migration check to fail because it tries to insert duplicate rows into the new schema.
+ *
+ * FIXME Currently, apps don't have a way of repairing anything before the migration check:
+ * @link https://github.com/owncloud/core/issues/10980
+ *
+ * As a result this repair step needs to live in the core repo, although it belongs into search_lucene:
+ * @link https://github.com/owncloud/core/issues/10205#issuecomment-54957557
+ *
+ * It will completely remove any rows that make a file id have more than one status:
+ * fileid | status fileid | status
+ * --------+-------- will become --------+--------
+ * 2 | E 3 | E
+ * 2 | I
+ * 3 | E
+ *
+ * search_lucene will then reindex the fileids without a status when the next indexing job is executed
+ */
+ public function run() {
+ if (\OC_DB::tableExists('lucene_status')) {
+ $this->emit('\OC\Repair', 'info', array('removing duplicate entries from lucene_status'));
+
+ $connection = \OC_DB::getConnection();
+ $query = $connection->prepare('
+ DELETE FROM `*PREFIX*lucene_status`
+ WHERE `fileid` IN (
+ SELECT `fileid`
+ FROM (
+ SELECT `fileid`
+ FROM `*PREFIX*lucene_status`
+ GROUP BY `fileid`
+ HAVING count(`fileid`) > 1
+ ) AS `mysqlerr1093hack`
+ )');
+ $query->execute();
+ } else {
+ $this->emit('\OC\Repair', 'info', array('lucene_status table does not exist -> nothing to do'));
+ }
+ }
+
+}
+