diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-01-07 09:14:35 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-01-07 09:14:35 +0100 |
commit | 604897945b01a368893661c0455072c0b390f7e8 (patch) | |
tree | d7adcb3122ad799ad60fb8999841b4d5b024dfa4 /lib/private/repair/innodb.php | |
parent | 470bf234c545ae5d0ad9c73834f8a596593791d6 (diff) | |
download | nextcloud-server-604897945b01a368893661c0455072c0b390f7e8.tar.gz nextcloud-server-604897945b01a368893661c0455072c0b390f7e8.zip |
Move lib/repair to lib/private/repair
Diffstat (limited to 'lib/private/repair/innodb.php')
-rw-r--r-- | lib/private/repair/innodb.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/private/repair/innodb.php b/lib/private/repair/innodb.php new file mode 100644 index 00000000000..ab94c79468d --- /dev/null +++ b/lib/private/repair/innodb.php @@ -0,0 +1,69 @@ +<?php +/** + * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OC\Repair; + +use Doctrine\DBAL\Platforms\MySqlPlatform; +use OC\Hooks\BasicEmitter; + +class InnoDB extends BasicEmitter implements \OC\RepairStep { + + public function getName() { + return 'Repair MySQL database engine'; + } + + /** + * Fix mime types + */ + public function run() { + $connection = \OC_DB::getConnection(); + if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) { + $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to do')); + return; + } + + $tables = $this->getAllMyIsamTables($connection); + if (is_array($tables)) { + foreach ($tables as $table) { + $connection->exec("ALTER TABLE $table ENGINE=InnoDB;"); + $this->emit('\OC\Repair', 'info', array("Fixed $table")); + } + } + } + + /** + * @param \Doctrine\DBAL\Connection $connection + * @return string[] + */ + private function getAllMyIsamTables($connection) { + $dbName = \OC::$server->getConfig()->getSystemValue("dbname"); + $result = $connection->fetchArray( + "SELECT table_name FROM information_schema.tables WHERE table_schema = ? AND engine = 'MyISAM' AND TABLE_NAME LIKE \"*PREFIX*%\"", + array($dbName) + ); + + return $result; + } +} + |