diff options
author | Joas Schilling <coding@schilljs.com> | 2016-10-18 11:10:55 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-10-19 00:15:01 +0200 |
commit | 15bbe0210670d5b23b265628209b9b3de50d0fd6 (patch) | |
tree | 1d58f2cebad6579edf879a94e8d2d3ee4887e14f /lib/private | |
parent | d0a3d17912cbbf31e6a5dd93aa190c48283de1cc (diff) | |
download | nextcloud-server-15bbe0210670d5b23b265628209b9b3de50d0fd6.tar.gz nextcloud-server-15bbe0210670d5b23b265628209b9b3de50d0fd6.zip |
Ignore failures of collation change in the pre update step
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Repair.php | 3 | ||||
-rw-r--r-- | lib/private/Repair/Collation.php | 38 |
2 files changed, 30 insertions, 11 deletions
diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 2ba118b9c37..7a5ef9fbd9e 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -129,6 +129,7 @@ class Repair implements IOutput{ */ public static function getRepairSteps() { return [ + new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false), new RepairMimeTypes(\OC::$server->getConfig()), new RepairLegacyStorages(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), new AssetCache(), @@ -179,7 +180,7 @@ class Repair implements IOutput{ $connection = \OC::$server->getDatabaseConnection(); $steps = [ new InnoDB(), - new Collation(\OC::$server->getConfig(), $connection), + new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true), new SqliteAutoincrement($connection), new SearchLuceneTables(), ]; diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php index c19b8eea5ec..54de1a719bd 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -24,28 +24,38 @@ namespace OC\Repair; +use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\MySqlPlatform; +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; class Collation implements IRepairStep { - /** - * @var \OCP\IConfig - */ + /** @var IConfig */ protected $config; - /** - * @var \OC\DB\Connection - */ + /** @var ILogger */ + protected $logger; + + /** @var IDBConnection */ protected $connection; + /** @var bool */ + protected $ignoreFailures; + /** - * @param \OCP\IConfig $config - * @param \OC\DB\Connection $connection + * @param IConfig $config + * @param ILogger $logger + * @param IDBConnection $connection + * @param bool $ignoreFailures */ - public function __construct($config, $connection) { + public function __construct(IConfig $config, ILogger $logger, IDBConnection $connection, $ignoreFailures) { $this->connection = $connection; $this->config = $config; + $this->logger = $logger; + $this->ignoreFailures = $ignoreFailures; } public function getName() { @@ -67,7 +77,15 @@ class Collation implements IRepairStep { foreach ($tables as $table) { $output->info("Change collation for $table ..."); $query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET ' . $characterSet . ' COLLATE ' . $characterSet . '_bin;'); - $query->execute(); + try { + $query->execute(); + } catch (DriverException $e) { + // Just log this + $this->logger->logException($e); + if (!$this->ignoreFailures) { + throw $e; + } + } } } |