diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-09-08 19:09:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-08 19:09:38 +0200 |
commit | 75c38d5d9862bea2945162226e9bc233872bfc74 (patch) | |
tree | 57d19ae34a55332d45a745d04c1021a4cec95080 | |
parent | c27b2f8dcf7a648060fb1cb8531e7d25c884e647 (diff) | |
parent | 29e1aa57e108853caaf2dcac84c4c75f19510f34 (diff) | |
download | nextcloud-server-75c38d5d9862bea2945162226e9bc233872bfc74.tar.gz nextcloud-server-75c38d5d9862bea2945162226e9bc233872bfc74.zip |
Merge pull request #6416 from nextcloud/make-sure-sqlite-works-without-content
Ask the schema whether the table and column exist
-rw-r--r-- | lib/private/Repair/Owncloud/SaveAccountsTableData.php | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/private/Repair/Owncloud/SaveAccountsTableData.php b/lib/private/Repair/Owncloud/SaveAccountsTableData.php index ae56004020d..c9e67356fb9 100644 --- a/lib/private/Repair/Owncloud/SaveAccountsTableData.php +++ b/lib/private/Repair/Owncloud/SaveAccountsTableData.php @@ -23,8 +23,6 @@ namespace OC\Repair\Owncloud; -use Doctrine\DBAL\Exception\InvalidFieldNameException; -use Doctrine\DBAL\Exception\TableNotFoundException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; use OCP\IDBConnection; @@ -86,20 +84,15 @@ class SaveAccountsTableData implements IRepairStep { * @return bool */ protected function shouldRun() { - $query = $this->db->getQueryBuilder(); - $query->select('*') - ->from('accounts') - ->where($query->expr()->isNotNull('user_id')) - ->setMaxResults(1); + $schema = $this->db->createSchema(); - try { - $query->execute(); - return true; - } catch (InvalidFieldNameException $e) { - return false; - } catch (TableNotFoundException $e) { + $tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts'; + if (!$schema->hasTable($tableName)) { return false; } + + $table = $schema->getTable($tableName); + return $table->hasColumn('user_id'); } /** |