Browse Source
Ask the schema whether the table and column exist
Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/6416/head
Joas Schilling
9 years ago
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with
6 additions and
13 deletions
-
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'); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|